File input/output: Difference between revisions

No edit summary
Line 329:
 
begin
#both files are closed automatically at the end of their attached blocks
of = File.new("output.txt", "w")
File.opennew("inputoutput.txt", "w").each_line do | line outputf|
of = File.newopen("outputinput.txt",) "w")do |inputf|
of.puts line
inputf.each_line do | line |
of outputf.puts line
end
end
end
rescue Exception => e
$stderr.puts "Exception raised: #{e}"
ensure
of.close
end
 
Anonymous user