Hi, thank you for your input.
I am sorry I was bothering you, because I think I was a little too hasty with my question. For some reason, the print-statement is not executed realtime, but only after the while over filehandle INP is finished. I don't understand why this buffering occurs in this case as normally it doesn't, but the code works fine anyway.