title: File Read and Write in tcl
body: <p>I saw some previous posts related to opening a file to perform read and write operations but I din't get an answer for my task. I want to append  some results to a file (should create a new file if it does not exist).<br>
        However, if the file already has  result then append should be skipped and move on to next search for next result. I wrote a script for this and I have problem in reading the file. 
  The script is something like this:</p>
  
  <pre><code>proc example {} {
      set a [result1 result2  ... result n]
      set op [open "sample_file" "a+"]
      set file_content ""
      while { ![eof $op] } {
          gets $op line
          lappend file_content $line
      }
      foreach result $a {
          if {[lsearch $file_content $result] == -1} {
              puts $op $result
          }
      }
      close $op
  }
  </code></pre>
  
  <p>Note: In this script I find variable "line" to be empty {""}. I guess I have trouble in reading the file. Please help me with this</p>