title: Add data to end of a line in file C (without using second file)
body: <p>That's the file I have:</p>
  <pre><code>Line 1
  Line 2
  Line 3
  
  </code></pre>
  <p>And I want to add some character/string at the end of each line. I did some research but haven't found any solution that's not use an additional file. Here is what I came up with:</p>
  <pre><code>char c;
  FILE *fp1 = fopen(&quot;Test.txt&quot;, &quot;r+&quot;);
  while ((c = fgetc(fp1)) != EOF){
      if (c == '\n'){
          fseek(fp1, -2, SEEK_CUR); // the '\n' is 2 bytes
          fputs(&quot;X\n&quot;, fp1);
          fseek(fp1, 1, SEEK_CUR);
      }
  }
  </code></pre>
  <p>It appends the string but deletes the first n characters of the newline (n - is a length of the string that I want to input). Output:</p>
  <pre><code>Line 1 X
  ine 2 X
  ine 3 X
  
  </code></pre>