Safe file load function