The problem in a nutshell: BufferedReader is buffered, but so is, usually, standard input. Therefore, if you use a BufferedReader on standard input, there are two different buffers of different sizes (one in
Java, one in your OS's console driver), and filling up one won't necessarily fill up the other.
Anyway, you're using BufferedReader just to get the readLine() method; you can turn buffering off. Just use
That "1" says use a buffer size of one character -- i.e., no buffer.
You should generally do this any time you use BufferedReader with standard input.