Adding a bit more checking on file operations.