Added hacky error checking for case where https is linked instead of http.  A more robust solution is required, and may necessitate a rewrite of the script.