const fs = require('fs');
const line = "Writing this text to a file";
//fs.appendText
fs.writeFile('myfile.txt', line, err => {
if (err) throw err;
console.log('text to a file.');
});
fs.readFile('myfile.txt', 'utf8', (err, text) => {
if (err) throw err;
console.log(text);
});
Posted inJavaScript