It is most often used when someone wants to add/insert content to file programmatically, such as using Javascript function writefile, one can be able to create and write content to a file.
e.g.
const data = new Uint8Array(Buffer.from('Hello Node.js'));
fs.writeFile('message.txt', data, (err) => {
if (err) throw err;
console.log('The file has been saved!');
});