How to exit for loop while serial.available

I am new in programming and need some suggestion on programming of one arduino.
Background: I am using a XBee connected with PC and a Xbee+arduino (sensor too). I want to send a command from PC to the arduino side, the arduino side will get the command and send sensor data.
Now problem: I want the arduino will keep sending the data (current sensor data - so it will may change in value) suppose 20 times if there is no command from the PC side. What I mean that if after sending 5 sensor data, the arduino sees that there is another command from PC, it has to stop sending the sensor data; it will get the new command from PC, read it and then start sending again.
My requirement is that arduino will send sensor data after getting command from PC side, will keep sending for 20 times but in this meantime if new command comes, it will stop sending the sensor data, will read the command and then start once again to send the sensor data 20 times. I am not sure how can I write the code so that it will check in every loop whether there is any command from the PC or not. I know the below code is not even close for what I am looking for:

void loop()                     
{
  while (Serial.available()) {
    delay(2);
    char c = Serial.read();
    readString += c;
              }
   if (readString.length() >0) {
     Serial.println (readString);
     for (int i = 0; i < 20; i++) {     
    //Send the temperature, or send a simple message
     Serial.println ("The command has been received");
     }
   }
}
  while (Serial.available()) {
    delay(2);
    char c = Serial.read();

You KNOW that there is data to read, so you wait a while, then read it. Why? There is no earthly reason to wait.

     for (int i = 0; i < 20; i++) {

The middle clause of a for loop is the while condition. If you want to execute this loop while i is less than 20 and Serial.available() == 0, say that:

     for (int i = 0; i < 20 && Serial.available() == 0; i++) {

You need to reorganize how your program works. It should check for input and send one output, check for input and send the next output etc. That way it can be interrupted by the PC at any time.

...R

First you need to have a command terminator. Carriage return is commonly used. Read what ever is available from the serial port each time thru the loop, adding to readString each time. When you read a carriage return, process the received command and enable sending of sensor data. Don't forget to reset your buffer (readString) after you have processed the command.