Why is my code reading one line from input file. C++ Not sure
<p>Consider the following:    </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

int main()
{
int score;
char grade;
ofstream myfileo;
ifstream myfilei;
myfilei.open ("example.txt");
while (!myfilei.eof()) {
    myfilei &gt;&gt; score;


cout &lt;&lt; "Enter your score:" &lt;&lt; endl;
if (score &gt;= 90)
    grade = 'A';
else if (score &gt;= 80)
    grade = 'B';
else if (score &gt;= 70)
    grade = 'C';
else if (score &gt;= 60)
    grade = 'D';
else 
    grade = 'F';   
cout &lt;&lt; "Your grade was a" &lt;&lt; grade &lt;&lt; endl;
switch (grade) {
    case 'A': case 'B':
        cout &lt;&lt; "Good job" &lt;&lt; endl;
        break;
    case 'C':
        cout &lt;&lt; "Fair job" &lt;&lt; endl;
        break;
    case 'F': case 'D':
        cout &lt;&lt; "Failure" &lt;&lt; endl;
        break;
        default:
        cout &lt;&lt; "invalid" &lt;&lt; endl;
}
}
myfilei.close();
myfileo.close();
return 0;
system ("PAUSE");
</code></pre>

<p>}</p>

<p>This code only reads the last line from an <code>examples.txt</code> file which is full of "scores" formatted like this:</p>

<pre><code>95
21
41
78
91
</code></pre>

<p>Why doesn't the above code read in and output all lines?</p>

<hr>

<p>Edited now its just a endless loop</p>
