Instead of std::getline in line 21, use: input.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
When you read in the int in line 20, the new line (from the enter key) is left in the stream. Ignore says ignore characters until I see a new line ('\n').
The ...max() means ignore all characters before the new line. If you enter an int, 56 spaces and then hit enter, there would be 56 spaces and a new line left in the stream. You want to make sure that all characters up through the new line are ignored.