Adding some verbosity and fixing some read/write issues.

Reading/writing at the end of the input/output could cause some loss.