title: How to reach end of file correctly in C
body: <p>I am doing a C project related to my lesson. I need to read words from a file named file2.txt whose content: </p>
  
  <p>file2.txt:</p>
  
  <pre><code>stephen elis elis
  awkward
  hello bye
  
  stephen ayse
  goodbye 
  book picture pencil
  </code></pre>
  
  <p>I am using:</p>
  
  <pre><code>FILE *file = fopen("file2.txt" , "r");
  char word[15];
  while(!feof(file))
      {
          fscanf(file,"%s",word);
          printf("%s" , word);
          printf("\n");
  
      }
  </code></pre>
  
  <p>But when the words are printed the result is:</p>
  
  <pre><code>stephen
  elis 
  elis
  awkward
  hello
  bye
  stephen
  ayse
  goodbye
  book
  picture
  pencil
  pencil   --&gt; printed second time
  </code></pre>
  
  <p>Thus , last word is printed twice and I do not understand why. Please help me about fixing this error because time is limited to complete this error!
  Thank you...</p>