safeguard: do not read/write 0 bytes (iostream)
Merge pull request #1065 from alex85k/patch-skip-zero-rw

skip zero bytes reading or wrtiting