WriteCanonical2
Implements ISO's write_canonical/2: like WriteCanonical1, but writing to the output stream identified by the first argument (an alias or $stream(...) term) instead of the current output.
Throws
if the first argument is unbound.
if it does not identify an open channel.
(stream_type) if it identifies an input channel instead.
Fails, rather than erroring, if the channel is closed.