Fixes reading thread

No need to search in a 1-character string...
Correctly handles a premature disconnection

This will also happen if you mess up the SSH parameters (i.e. if you run
something other that knock on the other side).