1// Asynchronously:
2const fs = require('fs');
3
4fs.appendFile('message.txt', 'data to append', function (err) {
5 if (err) throw err;
6 console.log('Saved!');
7});
8
9// Synchronously:
10const fs = require('fs');
11
12fs.appendFileSync('message.txt', 'data to append');