WriteTo method bug fix.

WriteTo method bug fix. WriteTo method should use TextWriter from paramer rather than from context.