All I changed was those lines and my copy works.
Only thing I can think that could cause that error is if the bot can't contact the website somehow, so it's leaves the variables undefined rather than empty. Probably a firewall getting in the way at one of the ends.