$text = join '', grep $_ ne "$word\n", split /(?<=\n)/, $text;