A Prolog stream can refer to a file or to the user's terminal1. Each stream is used either for input or for output, but not for both. At any one time there is a current input stream and a current output stream.
Input and output predicates fall into three categories:
Initially, the current input and output streams both refer to the user's terminal. Each input and output built-in predicate refers implicitly or explicitly to a stream. The predicates that perform character and term I/O operations come in pairs such that (A) refers to the current stream, and (B) specifies a stream.
predicate_name/n (A) predicate_name/n+1 (B)
At the C level, you can define more general streams, e.g. referring to pipes or to encrypted files (see fli-ios-uds-est).