Added proper error checks when loading a source file