Correctly test for end-of-stream. (fixes #1)