[SOLVED]Flush serial input buffer

@nickgammon
Before if(serial.available()) im printing whatever is in buffer via Serial.println(Serial.available()) shouldnt it show me if there are 10 chars or more left? it shows only 1 char is left.

Robin`s method is working without any delay but that doesnt explain why my method isnt. I have to add delay as you said and things are getting better.

as always we are getting far from the main question
if while(serial.available()) serial.read(); is considered as a way of flushing the input buffer in many articles and @spycatcher also wondered why it isnt working for me I wanted first to show that it isnt working and then to understand why.