I have an
object = { line1: 123, line2: 456 };
and I'd like to write it into a text file.
The output would be like this when the text file is opened.
123
456
I have tried this but it won't work
var json_data = require(`${__dirname}/output.json`);
var objectlength = Object.keys(json_data).length;
for ( var i = 0; i < objectlength; i++ ){
console.log ( i );
var write_to_txt = fs.writeFileSync(`${__dirname}/output.txt`,
json_data.line+i, null, '\t');
}