stop reading from sensor when a value is reached?

I'm attempting to display a tweet when a sharp IR sensor "sees" a person in front of the project. The problem I'm having: connecting to twitter, displaying the tweet, etc takes a while and the sensor starts reading again before the tweet is fully read from the API, resulting in no tweets displayed.

Code like this works fine:

#include <SPI.h>

void setup() {
  Serial.begin(9600);
}

void loop() {

    //while there is no one there, read the sensor until there is someone there
    while (analogRead(0) < 100) {
      Serial.println(analogRead(0));
    }
    
    //now that there is someone there, do something
    Serial.println("sensor is now greater than 100");
  
}

But code like this seems to move to fast for the twitter part

#include <SPI.h>

void setup() {
  Serial.begin(9600);
}

void loop() {

    //while there is no one there, read the sensor until there is someone there
    while (analogRead(0) < 100) {
      Serial.println(analogRead(0));
    }
    
    //now that there is someone there, do something that takes a while
    <pseudocode> connect to twitter API, get a tweet, display it on LCD </pseudocode>
  
}

Thoughts? Does the loop belong at the end? Thanks from a code newbie!

it doesnt make a big difference if the loop is in the beginning or in the end,
because:
loop() is called again and again in an end-less loop from main()...
2.
u could send debug messages via Serial.print() during the twitter part...

What if you make a simple "switch"?

x = 0 > read from sensor
x = 1 > do not read from sensor

Why is it necessary to turn something like this off? Usually you can let the sensors run anyway and and on the reaction side you say when something should happen?

But if you need to just set yourself a stopvariable in the void setup like "stop=1;" , put your code in an if that its running as long stop is 1 and another if for your value goal sets the stop to another int.