change fs.write to fs.writeFile