[ Term I/O | Reference Manual | Alphabetic Index ]

# writeln(+Stream, ?Term)

The term Term is written on the output stream Stream according to the current operator declarations. Equivalent to write(Stream,Term), nl(Stream).

Stream
  Stream handle or alias (atom)
Term
  Prolog term.

## Description

Used to write the term Term (followed by a newline) on the output stream Stream according to the current operator declarations.

### Modes and Determinism

- writeln(+, ?) is det

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

### Exceptions

(4) instantiation fault
  Stream is not instantiated.
(5) type error
  Stream is not an atom or a stream handle.
(192) illegal stream mode
  Stream is not an output stream.
(193) illegal stream specification
  Stream is an illegal stream specification.

## Examples

       Success:
          ?- open(file1,update,s), writeln(s, X + 2),
             writeln(s, Y + 3), close(s).
          X = _90
          Y = _78
          yes.
          ?- sh('cat file1').
          _90 + 2
          _78 + 3
          yes.

    Error:
          writeln(S, a(b,c)).        (Error 4).
          writeln("string", a(b,c)). (Error 5).
          writeln(9, X + 2).         (Error 192).
          writeln(atom, X + 2).      (Error 193).

## See Also

writeln / 1, write / 1, write / 2