The removeFromHosts function leaves a blank line at the end of the hosts file, then the addToHosts function begins by adding a new line. So each up and halt results in another blank line added to the end of the hosts file.
Have solved locally by changing line 118: hostsFile.write(hosts) to hostsFile.write(hosts.rstrip)
The removeFromHosts function leaves a blank line at the end of the hosts file, then the addToHosts function begins by adding a new line. So each up and halt results in another blank line added to the end of the hosts file.
Have solved locally by changing line 118:
hostsFile.write(hosts)
tohostsFile.write(hosts.rstrip)