title: fprintf() on a new line of a file
body: <p>How i can make a new line at the end of a file to fprintf() user inputed text?
  My code right now is this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      int lines;
      int number;
      FILE *fp;
      printf("Insert random number: ");
      scanf("%d", &amp;number);
      fp = fopen("textfile.txt", "r");
      char ch;
      while((ch=fgetc(fp))!=EOF)
      {
          if (ch=='\n') {
              lines++;
          }
      }
      fclose(fp);
      fopen("textfile.txt", "ab");
      fseek(fp, lines, SEEK_SET);
      fprintf(fp,"%d", number);
      fclose(fp);
  }
  </code></pre>