title: Issue with fgets while loop
body: <p>At the moment I have something like this:</p>
  
  <pre><code>while(fgets(i, sizeof(i), stdin)!=NULL) {
      printf("%s", i);
      printf("line%d - j", j);
      j++
  </code></pre>
  
  <p>Which produces something like:</p>
  
  <pre><code>line1
  line1 - j
  line2
  line2 - j
  line3line3 - j
  </code></pre>
  
  <p>The problem I have is that the final line that I grab does not produce a new line and the second print statement continues to print on the same line.</p>
  
  <p>Does somebody know how to fix this so that it produces:</p>
  
  <pre><code>line1
  line1 - j
  line2
  line2 - j
  line3
  line3 - j
  </code></pre>