Guard against socket.gets being nil

In the situation where the socket has only one line to respond with, any
following gets to the socket need to take care to not assume there is a
non-nil response.