Must check for error on stdin in addition to checking for EOF.