Reading TXT files returns empty string

Why when I compile and run this code, does it always return an empty string, the sample txt file is written and saved with notepad and has over 300 lines of text, yet it iterates the while loop once and puts nothing to the console, setting a watch on "infileStr" showes it to be empty???
___________________________________________________

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
string infileStr;

ifstream infile1("ATA-SUB-CHP.TXT");
if(infile1.is_open())
{
while(!infile1.eof())
{
getline(infile1,infileStr);
cout << infileStr;
}
infile1.close();
}

else cout << "Unable to open file";

return 0;

}

____________________________________________________________________
I figured out my own problem,

I am using Visual Studio, and I had the text file in the wrong directory, when it did not find it it created it (same file name) with zero bytes... once I put the file in the correct directory, it read it fine...

Sorry, hope this helps another newbe like me (thats why I left it posted and not deleted!
Topic archived. No new replies allowed.