I'd probably reach for node.js for something like this...
var fs = require('fs');
var lines = fs.readFileSync('./somefile.txt','utf8')
.trim().split(/\r\n|\r|\n/g);
for (var i=0; i<lines.length; i++) {
lines[i] = i * +lines[i];
}
fs.writeFileSync(
'./outfile.txt'
,'urf8'
,lines.join('\n')
);
Easy peasy. That's off the top of my head so fs syntax may not be correct. I'd probably give it a quick run through in the node repl to start with.Why JS, I find that this type of scenario begs for a language that does coercion well... say what you will about JS, it does do that.