in reply to file duplication error

You code did not duplicate the data. Propably you did not show the important part. However, you should use strict and use warnings;. Check open for errors and propably use binmode on your filehandles. Here is a cleaned version from your code. Untested... Ups, add the flocks.
use strict; use warnings; use CGI qw/:standard/; use Fcntl ':flock'; my ( @dataWrite, @dataRead ); open( my $in, "<", "../Rules1.txt" ) or die $!; binmode $in; flock($in, LOCK_SH); @dataWrite = @dataRead = <$in>; flock($in, LOCK_UN); close $in; push @dataWrite, "Code1\n"; open( my $out, ">", "../Rules1.txt" ) or dienice("Can't open counter.t +xt: $!"); binmode $out; flock($out,LOCK_EX); print $out @dataWrite; flock($out,LOCK_UN); close $out; print "Content-type: text/html\n"; print("\n");
Boris