I have a log file in which I'm adding text.
Here is the code:
function appendText(text) {
fs.writeFile('file.log', text+'\n', {'flag':'a'}, (err) => {
if (err) {
return console.error(err);
}
console.log('Saved!');
});
}
usage:
appendText('some text here');
My issue is that it's not adding the text to a new line at the end of the file content but everything is being added as a single line.
How can I fix this?