The following gives an extra line of "TEXT:"
set fidin [open C:/data/tcl/idxr.1 r]
set fidout [open C:/data/tcl/idxtest1.txt w]
while {![eof $fidin]} {
set inline [gets $fidin]
set text "TEXT:"
set Compare1 [string range $inline 0 7]
set Compare2 "RESULTS;"
set Compare3 [string range $inline 0 6]
set Compare4 "ENDTEXT"
if {[string compare $Compare1 $Compare2] == 0} {
set outline $inline
} elseif {[string compare $Compare3 $Compare4] == 0} {
set outline $inline
} else {
append text $inline
set outline $text
}
puts $fidout $outline
}
set fidin [open C:/data/tcl/idxr.1 r]
set fidout [open C:/data/tcl/idxtest1.txt w]
while {![eof $fidin]} {
set inline [gets $fidin]
set text "TEXT:"
set Compare1 [string range $inline 0 7]
set Compare2 "RESULTS;"
set Compare3 [string range $inline 0 6]
set Compare4 "ENDTEXT"
if {[string compare $Compare1 $Compare2] == 0} {
set outline $inline
} elseif {[string compare $Compare3 $Compare4] == 0} {
set outline $inline
} else {
append text $inline
set outline $text
}
puts $fidout $outline
}