Fixed a bug when editing hosts file, added some more sanity checks too