Move writeFile to Util