# open Open a file for line I/O, returning an opaque channel handle. ## Syntax
[open $path]
[open $path $mode]
## Parameters - `$path` — Path to a file. - `$mode` — (optional) One of `"r"` (read, default), `"w"` (write, truncates), `"a"` (append), `"rw"` (read/write). ## Examples
set chan [open "/tmp/log.txt" "w"]
[puts $chan "first line"]
[close $chan]

set in [open "/tmp/log.txt"]          # mode defaults to "r"
set line [gets $in]                   # => "first line"
[close $in]
## Returns An opaque `%Chan` channel handle, or `%Err{:message}` if the file can't be opened (check with `err?`). Never a raw file descriptor — descriptors are process-global and un-GC-able, so they don't appear as values. Channels are closed explicitly with `close`, or automatically by the GC when the handle is dropped. ## See Also `close`, `gets`, `puts`