#!/usr/bin/perl -w

#define files to read from and write to
$READFILE = 'read.txt';
$WRITEFILE = 'write.txt';

#open the READFILE to reading only (<).
open FILEHANDLE, "<$READFILE" || die "Can't open file.  $!";

#read the file, line by line, and print it to screen 
while (<FILEHANDLE>)
{
  print;

}

close FILEHANDLE;

#now open WRITEFILE for writing (>)
open FILEHANDLE, ">$WRITEFILE" || die "Can't open file. $!";

#for the numbers 1-5, print them to file, on their own line
foreach (1..5)
{
  print FILEHANDLE "$_\n";

}

close FILEHANDLE;
