Added exception handling for bad files or missing files