I'm trying to write a text file from node.js where the contents will be calculated line by line so building a string for writing in one shot would take quadratic time, and writing line by line seems the best option.
Basically I'm trying to do something along the lines of:
FILE *f = fopen("foo.txt", "w");
for (int i = 0; i < 100; i++)
fprintf(f, "line %d\n", i);
What's the node.js equivalent?