I tried a program in tcl to map the id number in mstate.txt with the name in instID.map.gz and print the names in other file with name file.txt
But the problem is how to declare fp3 as global variable . Since each time i am calling procedure the file file.txt is over written which i dont want.

```
set fp2 [open mstate.txt r]
set fp3 [open file.txt w]

proc mapping {n} {
    set b [lindex $n 0]
    set pipeline [open "| zcat  instID.map.gz"]
    set file_data [read $pipeline]
    set data [split $file_data "\n"]
    foreach line1 $data {
        set column2 [lindex $line1 1]
        set column1 [lindex $line1 0]

        if {[string equal $column2 $b]} {
            puts $fp3 " $column1   [lrange $n 2 end] "
        }
    }
}

while {[gets $fp2 line] >=0} {
    mapping $line
}
close $fp2
close $fp3

```