I'm trying to figure out how to use File.

I want to read each line, process it, print that to another file, and then
rename the output file.  This is how I'd do it in Perl:

open ORIG, "<$filename";
open TEMP, ">.$$.tmp";

while (<ORIG>) {
    s/<pre>/<code>/g;
    s/<\/pre>/<\/code>/g;
    print TEMP
}
close ORIG;
close TEMP;

rename ".$$.tmp", "$filename";


I can do the REGEX part:

line.gsub!(/<pre>/, '<code>')
line.gsub!(/<\/pre>/, '</code>')

But I need help with File.

Thanks,
Daniel.