How to read serial data sent in through the GPS and to store it in a string

I'm using Arduino uno to interface with a GPS module. There are some complications while receiving the serial data. How to convert this received byte into a string ?

String string= "";
void setup()
{
    Serial.begin(9600);
}

void loop() {
    string = "";
    while(Serial.available() > 0)
    {
        string += (char) Serial.read();
        Serial.flush();
     }
    if(string != "")
    {
       Serial.println(string); 
    }

}

This code doesn't seem to be working as the GPS data is nt being saved in the string.
Is there an alternative?

Serial.read() returns only one character at a time.

        string += (char) Serial.read();
        Serial.flush();

To me this means 'read one character and throw away any others that are available'

Have a look at this page Gammon Forum : Electronics : Microprocessors : How to process incoming serial data without blocking

To me this means 'read one character and throw away any others that are available'

That depends on the version of the IDE. Prior to 1.0, that's exactly what happens.

Post 1.0, though, that says 'read one character and wait until the output buffer is empty'.

The real problem, though, appears to be that OP is using the ONE serial port to talk to both the GPS and the PC. That won't work.

Of course, OP said nothing about the GPS and how it's wired or where it is.

use software serial, and use 2 pins other than 0/1 .