buffered I/O when writing files, tweaks to comments and error handling