Fix for read(0) from ended stream

If you read(0) from an ended stream read() thinks that the
stream has ended even though there may still be state
in the internal buffer.