fixed input and output bug

Fixed bug where reads and writes threw an error when requesting a full read or
write of zero bytes. Now, the functions simply return without error.