serial.available()==0, doesn't wait for input

Try while(!Serial.available());