loop for valid user input c++
===

New to C++ but I have some programming experience...

I'm trying a very basic approach to getting a filename from the user, then opening the file. I'm using some non-standard libraries (Stanford libraries), but I don't think that should affect things.

         ifstream in;
	while(true){
		string filename="";
		cout << "Enter the name of the file. ";
		getline(cin, filename);
		in.open(filename.c_str());
		if (in.fail()){
			cout << "ERROR opening file. Try again.";
		} else {
			break;
		}
	}
         ... more code ...

If I enter a valid file name first time, it works fine and moves on. If I enter an invalid file name, I get the error message and it loops around to ask for another file name, but then it treats all subsequent entries as invalid even if the file is valid. Any ideas what I'm doing wrong?  Thanks!