Added error handling for invalid file names
Added exception handlers for invalid file name errors.