Better exception handling for files.