Fixed logic to save a redundant API call if file exists