moves file download outside of loop