changes to ensure writeFile is only called once