In general, everything that can be used for good purposes can be used for bad purposes.
How do I monitor all internet usage through a particular router?
1. (Because I need to monitor my employees)
2. (Because I am doing a scientific study on internet page attention and retention)
The exact same technical question can be construed as good or bad based on that.
In this case, the OP was asking how to extract information from a textfile based on a keyword, he chose the name of his girlfriend as an example. Maybe he's a bad dude who's trying to spy on her, and maybe he's just doing his job and he used her name in his example text.
Either way, technical questions deserve technical answers.
We have no way of knowing someone's intentions. And even if we trust this user with the technical information we're provided, that will in no way stop the untrustworthy person from coming along later with the exact same question.
We have to accept that many of the answers can be used for evil, but SO is designed to be a source of technical information, and so that's what it should be. You should answer the question.