Bug fix for host editing
Move file sanitise function so it can be re-used