Better error handling on download failures.
Use magic to guess the file type; if we downloaded a text file,
print at least the beginning of the error message in the file.
Allow 9 failed downloads instead of 4 before giving up.