Fixed download_file function