title: fgets - is omitting the last line in c
body: <p>Basically i am having problems with my code - this is homework so would rather not post it in here for obvious reasons. If it becomes truely important for me to do so then i will have to as i am so stuck.</p>
  
  <p>i am reading 2 text files and it also has a separator , these values come from the command line, just assume that the separator in this case is xx</p>
  
  <pre><code>File a
  a
  b
  c
  
  
  File b
  d
  e
  
  Output should be
  axxd
  bxxe
  cxx
  </code></pre>
  
  <p>the problem is that my code just doesn't do the last line correctly</p>
  
  <p>i get an output of </p>
  
  <pre><code>axxd
  bxxe
  </code></pre>
  
  <p>I hope you guys can gather what i am doing wrong without me posting all my code, but my logic works on this principle;</p>
  
  <pre><code>while not at the end of the file for files a and b
      get a line using fgets from a
      create a character pointer and set it to the first occurrence of \n in the line using strchr
      if the pointer isn't null
          set the pointers value to be the end of line
  
  get the line from b as above
  and now write the line from a, the separator and the line from b to file
  </code></pre>