Did you mean something like that?
set fo [open file a] foreach different_content {"text 1" "text two" "something else" "some content"} { puts $fo $different_content } close $fo
You open the file file in mode a (add) and write it to the file descriptor ( $fo in the example).
Update. If you want to add the contents of a variable, you need to change the script to:
set fo [open file a] foreach different_content [list $data1 $data2 $data3 $data4] { puts $fo $different_content } close $fo
bmk
source share