title: how to solve this I/O error in ruby
body: <pre><code>require 'fileutils.rb'
  
  k=FileUtils.mkdir_p "d:/pptomasdsdr1xks_6b27"
  
  filename = "#{k}""/kddabab"  
  extension = ".txt"  
   co=1
  
    $stdout=File.open("#{filename}#{co}#{extension}" ,'w') 
  
  puts "sachin" 
  
  $stdout.close
  
  puts "amit" 
  </code></pre>
  
  <p>im getting error like</p>
  
  <p>stdout.rb:14:in <code>write': closed stream (IOError)
      from stdout.rb:14:in</code>puts'</p>
  
  <p>i don't want amit to be printd in my file so that i close the file but i got this error
  help me plzzz</p>