Let executables check and report errors properly
Report write errors the same way as reading errors
Merge pull request #53 from jmendeth/examples-error-checking

Properly check errors in executables