can't get c++ file to be readable infile.good()
<p>I'm writing a program and the first time it runs it creates and writes to a file and later in the program its supposed to read from that text file but the good() returns false. if I run the program a second time it will read and write perfectly.</p>

<pre><code>while(!done) {    //loop thats not supposed to end 
//code that has nothing to do with file
infile.seekg(0,ios::beg);   
while(infile.good() &amp;&amp; !infile.eof()) {
//reads file line by line
}
ofstream file(fileName, ios::app);
file &lt;&lt; s+"\n";
file &lt;&lt; m+"\n";
file.close();
</code></pre>

<p>it always writes fine but the first time I run the program and the text file is new later the program will not go into this while</p>

<p>if I close the program and run it again it'll go into the while and work perfectly I can't figure it out any help would be very much appreciated. I've tried putting  </p>

<pre><code>if(!infile.good()){ 
ofstream file(fileName) 
}
</code></pre>

<p>at the beginning of the file but that doesn't do anything but create the file earlier in the program and still have same problem. this is my first c++ program and its a big grade.</p>
