Create a fetch_file method to remove code duplication.