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