How to check if EOF (after using getline) <p>See update below!</p> <p>My code (now I included more):</p> <pre><code>while(getline(checkTasks, workingString)){ countTheDays = 0; // Captures a clean copy of the line in tasks.dat in it's entirety, stores in workingString. char nlcheck; checkTasks.get(nlcheck); if(nlcheck == '\n'){ } else{ checkTasks.unget(); //getline(checkTasks, workingString); // Breaks that line up into more usable pieces of information. getline(check2,tName, '\t'); getline(check2,tDate, '\t'); getline(check2,trDate, '\t'); getline(check2,tComplete, '\n'); // Converts the string form of these pieces into usable integers. stringstream(tDate.substr(0,tDate.find_first_of('/'))) &gt;&gt; year; stringstream(tDate.substr(tDate.find_first_of('/')+1,tDate.find_last_of('/'))) &gt;&gt; month; stringstream(tDate.substr(tDate.find_last_of('/')+1,tDate.length()-1)) &gt;&gt; day; stringstream(tComplete) &gt;&gt; checkComplete; stringstream(trDate) &gt;&gt; checkReminder; // Adds the number of days until your task is due! if(year != date[0]){ for(int i = date[1]; i &lt;= 12; i++){ countTheDays += System::DateTime::DaysInMonth(date[0], i); } countTheDays-= date[2]; for (int i = 1; i&lt;= month; i++){ countTheDays +=System::DateTime::DaysInMonth(year, i); } countTheDays -= (System::DateTime::DaysInMonth(year, month) - day); } else if(month != date[1]){ for(int i = date[1]; i &lt;= month; i++){ countTheDays += System::DateTime::DaysInMonth(date[0], i); } countTheDays -= (date[2]); countTheDays -= (System::DateTime::DaysInMonth(year, month) - day); } else{ countTheDays+= System::DateTime::DaysInMonth(date[0], month); countTheDays -= (System::DateTime::DaysInMonth(year, month) - day); countTheDays -= date[2]; } // If the task is nearing it's due date (the time frame specified to be notified) it'll notify user. // Only coded to work if the task is due in the current or following months. if(countTheDays &lt;= checkReminder){ if( countTheDays &lt; 0){ cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; tName &lt;&lt; " is past due!" &lt;&lt; endl; cout &lt;&lt; "Should I keep reminding you about this task? Enter Y or N. "; cin &gt;&gt; continueToRemind; } else{ cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; tName &lt;&lt; " is due in " &lt;&lt;countTheDays &lt;&lt; " days! Don't forget!" &lt;&lt; endl; cout &lt;&lt; "Should I keep reminding you about this task? Enter Y or N. "; cin &gt;&gt; continueToRemind; } // If user doesn't want to be reminded, begins process of converting that line in the file to usable info // and 'overwriting' the old file by creating a new one, deleting the old one, and renaming the new one. if(continueToRemind == "n" || continueToRemind == "N"){ fileModified = true; string line; /* vector&lt;string&gt; lines; while(getline(tasksClone, line)){ lines.push_back(line); } lines.erase(remove(lines.begin(), lines.end(), workingString), lines.end()); if (!lines.empty()) { auto i=lines.begin(); auto e=lines.end()-1; for (; i!=e; ++i) { saveTasks &lt;&lt; *i &lt;&lt; '\n'; } saveTasks &lt;&lt; *i; }*/ // This writes a copy of the tasks.dat file, minus the task that the user elected not to be notified of.' while(getline(tasksClone, testBuffer)){ if(testBuffer == workingString){ // This condition does nothing. Essentially erasing the 'completed' task from the list. } else if(testBuffer != workingString &amp;&amp; tasksClone.eof()){ // This writes everything except the specified task to taskbuffer.dat saveTasks &lt;&lt; testBuffer; } else { saveTasks &lt;&lt; testBuffer &lt;&lt; '\n'; } } } } } } } else{ cout &lt;&lt; "The tasks file is empty, you must not have any tasks!" &lt;&lt; endl; } </code></pre> <p>I hope that question makes sense!</p> <p>Thanks</p> <p>Marcus</p> <p>UPDATE: Reworked the code, again. After telling it to delete 1 task, it never runs this loop. Current code:</p> <pre><code>while(getline(tasksClone, testBuffer)){ if(testBuffer == workingString){ // This condition does nothing. Essentially erasing the 'completed' task from the list. } else if(testBuffer != workingString &amp;&amp; tasksClone.eof()){ // This writes everything except the specified task to taskbuffer.dat saveTasks &lt;&lt; testBuffer; } else { saveTasks &lt;&lt; testBuffer &lt;&lt; '\n'; } </code></pre> <p>} </p> <p>Input file:</p> <pre><code>test1 2012/12/13 10 0; test2 2012/12/23 20 0; test3 2012/12/31 28 0; \n </code></pre> <p>Output file (after telling it to delete test1 and 2):</p> <pre><code>test2 2012/12/23 20 0; test3 2012/12/31 28 0; \n </code></pre>