"e.g. I type: 2 Hello World hello world and it stucks"
How do you type it? There has to be a newline beween every word, if not, this is only one line so the program still waits for the second line (because you entered 2).
If you want the spaces to be the delimiters, just replace getline(cin, count);
by cin >> count;
and let cin.ignore();
away in every case (see chris comment).