Improved error handling for files.
Added inout example