Communication with the PC problem!

And, you should read up on what flush() does, now. It blocks until the outgoing serial buffer is empty. Hardly useful in your situation.

There is no means of emptying the incoming serial buffer without reading everything. For good reason.