fixed writeFile()