open DATA, ") { if(m/\END\b/) { print "$.\n"; print "$_\n"; $pos = $.; $pos--; chomp $pos; $DESIRED_LINE_NUMBER = $pos; } } #$. = 0; do { $LINE = } until $. == $DESIRED_LINE_NUMBER || eof; print $LINE; #### Result: 1675 ---> Line found matching Search # *** END NEW MAPPING RULES SECTION *** ---Txt from Line -->Blank Line where I need to add values.