in reply to
problem while searching for a pattern in a file
I have executed your program in my system.It sent the mail only if the pattern get matched.
I have tested your code with the following input.
contents of results.txt
This is testing
In this case mail didn't send.
This condition will match the pattern other than "hello".
So when newline is encountered this condition will get true.(\n!="hello").
So in this case also mail will send.