First, fix: std::vector<std::string>lines; while(!file.eof()) { file >> str; lines.push_back(str); std::getline(file,str); Descriptions.push_back(str); n++; } Dunno exact behavior, but it looks like you are copying file into str multiple times, and you also forget to add '\n' onto descriptions. Oh,...