for i in range(len(text)):
    stdout.write(text[i])
Зачем так извращаться? Текст прекрасно итерируется:
for x in text:
     sys.stdout.write(x)