nit: can we use writeFile() in both these places?