http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/seek.htm
Example (no error handling done here - be sure to do some in real life!) :
% cat /tmp/mydata 1234567890abcdefghijklmnopqrstuvwxyz % set f [open "/tmp/mydata" "a+"] file3 % seek $f 20 % puts -nonewline $f "KLM" % close $f % cat /tmp/mydata 1234567890abcdefghijKLMnopqrstuvwxyz
One interesting use for seek is to constrain the size of output files. [...]
Tcl syntax help - Arts and crafts of Tcl-Tk programming - Category Command