used writeFilySync instead of writeFile