From the PHP documentation of
Each line has length of
$C characters + the EOL. When you call
stream_get_line(STDIN, $C, "\n") for the first time, it will indeed read
$C characters but it won’t consume the EOL so the next call will immediately see this EOL and return an empty string.
When you want to be sure to read the whole line, you can use
fgets(STDIN) then trim the EOL.