title: Need to write specific columns in output file using tcl
body: <p>I am trying to read a file with 5 columns( separated using space delimiter)</p>
  <pre><code>#text  tag    x     y     data_lay
  
  bad    bad1   10.0  10.0   L1
  
  good   goodn  13.0  11.0   L1
  </code></pre>
  <p>And trying to output the specific columns with a prefix on the first column in a new file. Output format should be like following</p>
  <pre><code> Add_obj bad  10.0 10.0 L1
  
   Add_obj good 13.0 11.0 L1
  </code></pre>
  <p>I tried the following but has been unsuccessful in getting the anticipated output. Here, is the snippet of the code</p>
  <pre><code>set fp [open [lindex $argv 0] r]
  
  set colData {}
  
  while {[gets $fp line]&gt;=0} {
  
      if {[llength $line] ==4 } {
     
          set colData [split $line “ “]
     
           puts “Add_obj [lindex $colData 0] [lindex $colData 2] [lindex $colData 3] [lindex $colData 4]”
     
      }
  }
  
  close $fp 
  </code></pre>
  <p>Could you please help with a sample code?
  Thanks.</p>