What you are likely running into is that telnet is an interactive application. The buffering that Perl does to read input by lines destroys the interactivity. When the user hits the first key of their username, they expect to see it echoed immediately. But Perl is still sitting there waiting for the end of the line.
Luckily, you only need to process the header. Once you finish reading the header, you can stop reading line by line. Either enter a loop that reads and writes a single character. Or find some way to reconnect the telnet stdout to the Perl stdout.