removing part of lines that start with curly brace



I want to scan a file line by line & remove all text after (and
including) a curly bracket, e.g.

Set vhdl file "fred is fat"{ krqffqo234fr

to become:

Set vhdl file "fred is fat"

but having problems with recognising the curly bracket.

so far i've tried:


#-------------------------------------------------------------------------------
proc myputs {instring} {
set len1 [expr [string first } $instring] - 2]
set str1 [string range $instring 0 $len1]
return $str1
}
#-------------------------------------------------------------------------------
package require Tk

set types {
{{HDL files} {.hdp} }
{{Text Files} {.txt} }
{{TCL Scripts} {.tcl} }
}

# Get the filename & directory etc for modifying.
set f1_fullname [tk_getOpenFile -filetypes $types]
# Extract the directory pathname.
set f1_dir [file dirname $f1_fullname]
# Extract just the file name without the path.
set f1_name [file tail $f1_fullname]
# Extract the name before the filename-extension.
set f1_head [file rootname $f1_name]
# Move to the directory
cd $f1_dir
# Open the file for reading
set f1 [open $f1_name r]

# Open a new file for re-aligned version
set f2 [open $f1_head.txt w]

# Copy file, while reformatting lines
while { [gets $f1 inline] >= 0} {
if { [string length $inline] > 0} {
if {[regexp { \} } $inline]} {
puts $f2 [myputs $inline]
} else {
puts $f2 $inline
}
}
}

# Now rename the files
close $f1
close $f2
file rename -force $f1_head.tcl $f1_head.oldfile
file rename -force $f1_head.txt $f1_head.tcl

exit

Can anyone enlighten me please?
.