title: Difference between ifstream.good() and bool(ifstream)
body: <p>I'm writing a program which takes several variables from a text file.
  When the program finds EOF,<br>
  it ends entering data.</p>
  
  <pre><code>int main()
  {
      int val, count = 0;
      ifstream fileIn;
      fileIn.open("num.txt");
  
      fileIn &gt;&gt; val;
      while (fileIn)
      {
          ++count;
          cout &lt;&lt; "number: " &lt;&lt; val &lt;&lt; endl;
          fileIn &gt;&gt; val;
      }
      cout &lt;&lt; "count: " &lt;&lt; count &lt;&lt; endl;
  
      fileIn.close();
      return 0;
  }
  </code></pre>
  
  <p><code>num.txt</code> file: <code>11 22 33 44</code></p>
  
  <p>Program output:</p>
  
  <pre><code>number: 11
  number: 22
  number: 33
  number: 44
  count: 4
  </code></pre>
  
  <p>Everything is OK. But if I change the while condition section from <code>fileIn</code> to <code>fileIn.good()</code>,<br>
  the program output will look like this:</p>
  
  <pre><code>number: 11
  number: 22
  number: 33
  count: 3
  </code></pre>
  
  <p>It skips last value now.
  Why is this happening and what's the difference between <code>fileIn</code><br>
  and <code>fileIn.good()</code>?</p>