fix perms
add shebang
break out download into separate function