Use a fresh tempfile for each download attempt instead of reusing the same file (and having to rewind/truncate it after each failed attempt).
Use a fresh tempfile for each download attempt instead of reusing the same file (and having to rewind/truncate it after each failed attempt).