title: Removing space from string after reading it from file using TCL
body: <p>I am trying to read a file line by line and wanted to remove the white space characters if any using TCL.</p>
  
  <p>I am using trim command to remove the spaces, but it is not getting trimmed. </p>
  
  <p><strong>details.config</strong> (Input file)</p>
  
  <pre><code>sys_username = dinesh
  sys_password = dinesh
  ftp_ip = 0.0.0.0
  ftp_username = ftpuser
  ftp_password = ftppassword
  </code></pre>
  
  <p><strong>mystr_example.tcl</strong></p>
  
  <pre><code>#!/usr/bin/expect
  set config_file "details.config"
  
  set file_handle [open $config_file]
  while {[gets $file_handle line] != -1} {
  #set line [ string trim $line ] (I thought this might be wrong)
  #set line [ string trim $line " "] (even if we didnt give the 2nd argument, 
  # then it has to remove the whitespaces. Correct ? ) 
  #Just copying it to another variable
  set test $line
  #Now, trimming and saving it to variable 'final'
  set final [string trim $test]
  #set final [string trim $test " "] ---&gt; Tried this too
  puts "--&gt;  $final";
  }
  
  #Below example, I found from internet which is working fine.
  set str "      hello world      "
  puts "original: &gt;$str&lt;"
  puts "trimmed head: &gt;[string trimleft $str]&lt;"
  puts "trimmed tail: &gt;[string trimright $str]&lt;"
  puts "trimmed both: &gt;[string trim $str]&lt;"
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>--&gt;  sys_username = dinesh #Spaces are still there in output
  --&gt;  sys_password = dinesh
  --&gt;  ftp_ip = 0.0.0.0
  --&gt;  ftp_username = ftpuser
  --&gt;  ftp_password = ftppassword
  
  original: &gt;      hello world      &lt;
  trimmed head: &gt;hello world      &lt;
  trimmed tail: &gt;      hello world&lt;
  trimmed both: &gt;hello world&lt; #Spaces removed here
  </code></pre>
  
  <p>What went wrong here?</p>