Minor refactoring in download_file