title: read word by word from file in C++
body: <p>this function should read a file word by word
  and it does work till the last word, where the run stops </p>
  
  <pre><code>void readFile(  )
  {
      ifstream file;
      file.open ("program.txt");
      string word;
      char x ;
      word.clear();
  
      while ( ! file.eof() )
      {
          x = file.get();
  
          while ( x != ' ' )
          {
              word = word + x;
              x = file.get();
          }
  
              cout&lt;&lt; word &lt;&lt;endl;
              word.clear();
  
      }
  }
  </code></pre>
  
  <p>any one see what is the problem and how it can be solved??</p>