(refactor) Check that file exists before using it