in reply to file duplication error

You seem to be just overwriting your original file. That's not my idea of "duplicating a file". If you just happen to run the script twice, it'll append "Code1" twice. That's normal, I would think.

You're really going through a lot of trouble to copy the contents of an array, where a simple

@dataWrite = @dataRead;
would do.

Nowhere do you actually look at what @dataRead contains, after you modify @dataWrite. How would you know it changed? It didn't, I'm sure.

Oh, and this:

open(fileOUT,">../Rules1.txt") or dienice("Can't open counter.txt: $!" +);; flock(fileOUT,2); seek(fileOUT,0,0);
is a recipe for disaster: first you open the file for writing, clearing it in the process, and then you try to lock it. Too late. You can try replacing ">" with ">>", and add
truncate fileOUT, 0;
at the bottom. It might work, it surely would on some platforms.