Made writeq handle cyclic terms -- before write handled cyclic terms, but not writeq.
In the process, fixed a couple of cases where write hadn't properly been handling cyclic terms.
Authored by: tswift 2018-07-18
Parent: [r9407]
Child: [r9409]