fix bug in stdout.write()