Write a Node.js code to write a string "Hello world" 10^5 times in a file using stream writer in Node.js.
I have tried using loops but there is out of memory error and the system hangs.
Any better method?
var fs = require('fs');
var wstream = fs.createWriteStream('D:\\myOutput.txt');
for(var i=0;i<10^5;i++){
wstream.write('Hello world!\n');
}
wstream.end();