proc checkline {string} { set f [open filename.txt r] set found [checkfile $f $string] close $f if {$found != "0"} { set f [open filename.txt a] puts $f "whatever" close $f } } proc checkfile {f string} { while {![eof $file]} { gets $file line set line [split $line " "] if {[string eq -nocase "WorldTime" [lindex $line 0]] == 0} {return [lindex $line 1]} return 0 } }