in reply to clear STDIN

You must not have posted the complete code. When I run your routine, I get the first print, and then it waits until I enter a line, and then I get the second print, and it waits until I enter a line.