Well, pressing enter doesn't tell the program it has reached the end of the file - how does it know you aren't going to type in more numbers on the next line?
Either redirect the input from a file on the command line, which is probably a better idea anyway, or use ctrl-z to signify EOF when entering input.