title: Why does Ruby say Closed Stream IOError?
body: <p>I have a problem with my program. It says: "`write': closed stream (IOError)".</p>
  
  <pre><code>def backup(dir, file, time="")
      fullpath = "#{dir}/#{file}"
      #puts fullpath
  
          @f.puts "BKP_DATE: #{$date}"
          @f.puts "BKP_DIRECTORY: #{dir}"
          @f.puts "M_TIME: #{time}"
          @f.puts "BKP_FILE: #{file}"
  
  
          IO.readlines(fullpath).each do |line|
  
              @f.puts line
          end
          @f.close()
  
  end
  </code></pre>