The >> operator only reads what's necessary to get the value so the rest of the line remains in cin ready be read by the next read operation. This can be a problem when using the getline function because the way it works is that it just reads input until it finds a newline character so in this case it will just find the newline character that was left over from when you inputted Y or N and return an empty string. The easiest way around this is to always discard all leading whitespace characters (spaces, tabs, newlines) before trying to read the line. I suggest always using getline this way, it's almost always what you want.
getline(cin >> ws, name)
You might also want to move the printing of the question from line 1 to line 21 because otherwise it will only ask before the loop start and not every time. You might also want to move line 4 to the end of the loop so that you don't have to answer the question the first time.