var fs = require('fs');
for(var x = 0; x < 10; x++){
fs.open("file.txt", 'a',function(err, fd){
if(!err){
fs.write(fd, x.toString() + "\n");
}
});
}
This prints out a bunch of 10s. I made the program to print out 0-9. For some reason, the code inside fs.open cannot access the x variable correctly. Can anybody explain? Is there an issue with scope?