title: multiple lines of code in stream.forEach
body: <p>I have the following code for reading lines of a file:</p>
  
  <pre><code>String fileName = "dataset/ANC-all-count.txt";
  Integer i=0;
  //read file into stream, try-with-resources
  try (Stream&lt;String&gt; stream = Files.lines(Paths.get(fileName), StandardCharsets.ISO_8859_1)) {
  
      stream.forEach(System.out::println);
      i++;
  
  } catch (IOException e) {
      e.printStackTrace();
  }
  System.out.println("count is : "+i);
  </code></pre>
  
  <p>but the problem is I need to put <code>i++</code> inside the following line:</p>
  
  <pre><code>stream.forEach(System.out::println);
  </code></pre>
  
  <p>So I want something like this:</p>
  
  <pre><code>stream.forEach(System.out::println; i++);
  </code></pre>
  
  <p>But it does not work this way so can anyone help how I can make it work?</p>