One problem is that you do not check if you were successful in opening the file. However, the likely cause of your problem is that you attempt to write to elements of the vector, but the vector is empty. A possible fix for this is:Originally Posted by ineedmunchies
However, you still cannot just assume that after the loop strVector will have at least three elements; you should check before you access strVector[2].Code:vector<string> strVector; string line; while (getline(myfile, line)) { strVector.push_back(line); }