in reply to I can't find my mistake here!!!

Most likely, your $sequence never matches ABC. Alternatively, maybe opening the file failed. Use

open OUT, '>', "$infile.OUTFILE" or die "Couldn't create file '$infile.OUTFILE': $!";

Also, consider printing both to STDOUT and to OUT, just to debug that what you think should be printed to the file really gets printed.