You should only put std::getline() in a while() loop when you don't know how many lines you will read, and you decide to read them all, right to the end of the file.
However in this case you know that you want to read a total of two lines: one in line1 and the other in line2.
So simply use the std::getline() outside a while() loop.
Also, practice and improve your indent style (it will make the code easier to read).