Using an if-then test, you can evaluate the exit status of a command. For example:
if grep string filename
<do something here>
note there aren't parentheses around the test condition, since it evaluates a command, not an expression. However, you can accomplish your task in a single step using sed, for example
sed 's/string_to_delete//g' filename
that is you substitute the string to delete with nothing. The command above send the output (that is the modified content of the file) to the standard output. To edit the file in place you have to add the -i option.
The problem is to choose a regexp that matches only the string you want to delete. Can you provide a real example of what should be the content (or a relevenat part of it) of the file and the string to match?