However, this would overwrite the file if there was any previous information in it. To avoid that, we can append to a file using a different mode like this.
xxxxxxxxxxconst fs = require('fs');fs.appendFile('filename.txt', 'Appending to existing file', function (err) {  if (err) throw err;});OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment



