I copied the code straight from
https://www.w3schools.com/nodejs/shownodejs_cmd.asp?filename=demo_events_open
open.js
var fs = require('fs');
var readStream = fs.createReadStream('./demofile.txt');
/*Write to the console when the file is opened:*/
readStream.on('open', function () {
console.log('The file is open');
});
Upon executing "node open.js" in the terminal, "The file is open" appears in the terminal, then the program terminates. It always happens, even if I don't have demofile.txt open in Notepad or any other program. Not sure why this is happening?
Wh