my $ldir = "/Android"; $RESULTS_FILE = $ldir.'/'.'results.html'; open OUT, ">>", $RESULTS_FILE; open(IN,") { chomp; if( $_ =~ m/Unable to parse/ ) { my @string = split('/',$_); print @string; my $stream_name = $string[4]; while $srch() { chomp; if( $srch =~ m/$stream_name/ ) { // How to replace the line here? } } } }