Updated version, added error codes, cleaned up some whitespace and exit on write failure