Fixes #8732 by reading until EOF reached.

* use a lambda for cleaner iterator.
* also disables buffering, since we are reading byte-by-byte in the first place
and maintaining our own buffer (#data).
Oops, the default bufsize is 0 anyways.
Land #2859 - Fix sessions -c