fixed download script, adding directory creation
adding entries and tempfile ignore
making sure file closes