title: Why am I reading the last word in my file twice?
body: <p>I'm trying to read in the text from a file and this is what I am doing:</p>
  
  <pre><code>int main(int argc, char* argv[])
  {
  
  ifstream inFile;
  inFile.open(argv[1]);
  
  string item;
  
  while(inFile.good())
  {
    inFile &gt;&gt; item;
    cout &lt;&lt; item &lt;&lt; " " &lt;&lt; endl;
  }
  </code></pre>
  
  <p>For some reason it will read the last word in the file twice. I tried using a <code>count</code> variable to keep track of how many times it enters the while loop and it always enters one time more then the total number of line in the file. I think this is happening because the <code>inFile.good()</code> statement is not returning false soon enough. How can if fix it?</p>