title: print only once in "if loop" inside a "while loop"
body: <p>In linux ubuntu 14.04, I am trying to count the lines of input:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  /*count lines in input*/
  
  main()
  {
      int c, nl;
  
      nl = 0;
      while ((c = getchar()) != EOF) {
          if (c == '\n')
              nl = nl + 1;
          printf("input lines are %d\n", nl);
      }
  }
  </code></pre>
  
  <p>The output is however:</p>
  
  <pre><code>   asdsadsa
  input lines are 0
  input lines are 0
  input lines are 0
  input lines are 0
  input lines are 0
  input lines are 0
  input lines are 0
  input lines are 0
  input lines are 1
  asdasd
  input lines are 1
  input lines are 1
  input lines are 1
  input lines are 1
  input lines are 1
  input lines are 1
  input lines are 2
  </code></pre>