replaced console.log with process.stdout.write