[java] Using BufferedReader.readLine() in a while loop properly