in reply to Problem with STDIN

Print a newline at the end of your prompt. Unbuffering STDOUT and STDERR shouldn't make a difference (though I'm not positive on Windows):

print "Enter a number:\n";