Try this:
cspr.stdout.setEncoding('utf8');cspr.stdout.on('data', function(data) { var str = data.toString(), lines = str.split(/(\r?\n)/g); for (var i=0; iNote that the "data" event might not necessarily break evenly between lines of output, so a single line might span multiple data events.