fixed a bug in WriteString