Stopped checking characters on file write and improved exception handling