#! /usr/bin/perl -w

#  scr07B.pl
#  How to write an external file automatically?
#  Please use open (OUT, ">filename.txt") with the mark of redirection ">".


open (IN, "Infile.txt");             ###  FileHandle IN opens "Infile.txt" for reading.
open (OUT, ">Outfile.txt");          ###  FileHandle OUT opens "Outfile.txt" for writing.

while(<IN>){   
     print $_;              ##  For screen (terminal) monitor
     print OUT $_;          ##  Writing all of incoming each line into "Outfile.txt" by FileHandle OUT.
}

close (IN);          ### Close FileHandles IN and OUT.
close (OUT);