Early exit on EOF (fixes #21)