I have a text file with many lines. I want to store each line in a vector of strings. I want to read from the file until the last line is reached. I used the EOF function but it seems to store blank lines after the last line also. Here's a snippet of my code. text_list is a vector in which all the lines of the file are stored.
void TextBuddy::storeDataFromFileInVector(string filename){
ifstream infile;
int numbers;
string textMessage;
infile.open(filename);
while (!infile.eof()){
getline(infile, textMessage);
text_list.push_back(textMessage);
}
infile.close();
}