This should just return `RefWriter` instead of defining a new type. `RefWriter` can be made to implement `TextWriter` when its parameter does.

Below in `TextReader` you already do this, by returning `RefReader`. That may have been a mistake, of course, but I think it's the right action.