forgot to check for end of output