once you have read all lines of file B in the first outer cycle, you cannot read any more. the solution would be either to use istream::seekg or to read everything into vectors before printing the combinations.
//cycle 1:
getline (FileA,line);
//FileB was just opened so get ptr points to its beginning.
while( FileB.good() ){
getline (FileB,lineB);//get ptr moves forward
cout << line <<"-"<< lineB << endl;
}
//the inner loop ends when an error flag is set due to reaching end of file
//cycle 2:
getline (FileA,line);
//FileB has an error flag set, so this loop will not be entered. what can we do?
// first clear the flag (forgot this the last time) and then move the get pointer to the beginning.
//this is done with
FileB.clear();
FileB.seekg(std::ios::beg, 0);
//now FileB is readable again
while( FileB.good() ){
getline (FileB,lineB);//get ptr moves forward
cout << line <<"-"<< lineB << endl;
}
//the inner loop ends when an error flag is set due to reaching end of file
//... repeat as much as you like.
Now you just have to roll this back. I put that .clear, .seekg in a slightly awkward place (that is, I didn't show it on the first cycle), but you can put it anywhere before the second input operation. No harm can come from it.