Skip to content

Instantly share code, notes, and snippets.

@gabri83
Last active August 13, 2025 08:13
Show Gist options
  • Select an option

  • Save gabri83/41acc5d8b54773884b3a61692b2c024f to your computer and use it in GitHub Desktop.

Select an option

Save gabri83/41acc5d8b54773884b3a61692b2c024f to your computer and use it in GitHub Desktop.
Read a File Line by Line (Node.js)
const fs = require('fs');
fs.readFile('example.txt', 'utf8', (err, data) => {
if (err) throw err;
data.split('\n').forEach(line => {
console.log(line);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment