title: BufferedReader readLine() from standard input
body: <p>I need to read from the standard input. I am not that familiar with BufferedReader and have only used Scanner so far. Scanner (or probably something inside my code) keeps on giving me TLE. Now the problem is that BufferedReader seems to skip some lines and I keep on getting a NumberFormatException.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  
      int cases = Integer.parseInt(reader.readLine());
  
      for(int i = 0; i &lt; cases &amp;&amp; cases &lt;= 10; i++) {
          int numLines = Integer.parseInt(reader.readLine());
          String[] lines = new String[numLines + 1];
          HashSet&lt;String&gt; pat = new HashSet&lt;String&gt;();
  
          for(int j = 0; j &lt; numLines &amp;&amp; j &lt;= 10; j++) {
              String l = reader.readLine();
  
              String patternStr = "\\W+";
              String replaceStr = "";
  
              Pattern pattern = Pattern.compile(patternStr);
              Matcher matcher = pattern.matcher(l.toString());
  
              String m = matcher.replaceAll(replaceStr);
  
              lines[j] = m;
              getPatterns(m, pat);
  
              System.out.println(m);
          }
  </code></pre>
  
  <p>The error occurs after the second input. Please help.</p>