Rewrite error handling. Don't log.Fatal but pass the error along to the user of the library. If any files are created, delete them if something goes wrong.