I need to know how to remove content from a text file.

basically I am stripping attachments from an Email.

so

IF the text file contains the string
"Content-Type: application/"
Then
Delete the row above that line and everything after that line to the end of the doc


it looks like this

Code:
------=_NextPart_000_xxxxxxxrandomcharactersxxxxxxx
Content-Type: application/pdf;
asdf
asdf
asdfasdf
asdf
asdf
asd
fasd
fasd
fasdf
------=_NextPart_000_xxxxxxxrandomcharactersxxxxxxx
i would want to delete that entire chunk

anyone have any thoughts?