If I get it correctly it looks like you're outputting some text ( print("<BR>DOWNLOAD ATTEMPT 6<BR>") ) BEFORE sending the headers. This can't work, you must send the headers first, before anything else.
Then I think any of the proposed headers should work.