set handle [open $filename w] puts $handle $line close $handle
The Tcl man pages use the term channel.Unix calls the underlying construct a file descriptor.MHo 2017-05-19: I noticed that file handles are "recycled", so if a specific handle is closed, short after that a newly opened file gets the same handle.
ak - 2017-05-19 20:43:35That is, I believe, because of unix recycling the underlying file descriptor. I am not sure if it applies to Windows as well. The recycling of the standard channels OTOH is something Tcl does by itself IOW
close stdout open some/fileThe channel for some/file now is "stdout". Works for sockets, pipes, etc. The first new channel after closing one of stdout, stderr, stdin becomes that channel.