fix writeFile