I believe that would happen if stdin encountered EOF (i.e. ^D) during the call to `gets`.