Added some error handling;

Files are written back to disk