const fs = require('fs'); fs.readFile('file.txt', function(err, data) { if(err) throw err; const arr = data.toString().replace(/ /g,' ').split(' '); for(let i of arr) { console.log(i); } });