Type value; while(inFile >> value) { //loop body goes here. } if(inFile.eof()) { //terminated with EOF } else if(inFile.fail()) { //terminated with mismatch } else { //terminated with some reason unknown }