Good catch but it can be simplified a bit:
* You don't need `length`, work with count.
* Change `do-while` to `while (count > 0)`
* The previous change makes the check for `count == 0` unnecessary
* Move the `EndOfStreamException` throwing right after the `Read` call
* Btw, you will be asked to change all `int`s to `var`s (in other places too)

Last, this change is wanted, IMO, but should at least be a separate commit, if not PR.