Looks pretty good to me, at least to visual inspection, except that you try to read from F after you've already read the whole file into @F_cf (so there's nothing left to read). Replace your while loop with a for loop: for my $line (@F_cf) {
Not sure what the final rename is; do you mean to rename your new file to the old name inside the outer for loop.