>>>>> "R" == Raja S <raja / cs.indiana.edu> writes: Something like this ? ( but there is problem with flush) R> class File R> def File.with_output_to_file (fname, mode="w", &blk) R> begin R> dout = $defout stdout = $stdout.dup stderr = $stderr.dup R> $defout = File.open fname, mode $stdout.reopen($defout) $stderr.reopen($defout) R> yield R> ensure R> $defout.close $stdout.reopen(stdout) $stderr.reopen(stderr) R> $defout = dout R> end R> end R> end Guy Decoux