To append to New Line in Node.js, we use some file methods.
For instance, we write
const os = require("os");
const processInput = (text) => {
fs.open("H://log.txt", "a", 666, (e, id) => {
fs.write(id, text + os.EOL, null, "utf8", () => {
fs.close(id, () => {
console.log("file is updated");
});
});
});
};
to call fs.open to open the file.
Then we call fs.write to write the file with text and the os.EOL new line character.
We then close the file with fs.close after writing to it with the id.