Using writeFile instead of appendFile