Fix inconsistent use of `$this->writer` vs local variable