Wrap script in main function so that a truncated partial download doesn't end up executing half a script.