The cause that nothing is working is probably because you process the file line by line and the parts of the strings you are looking for are on different lines. You can slurp in the whole file by using the
-0 command line switch with an octal value that does not represent an existing character, as per
the docs.