If you are really worried about performance, for me the `bound to` line is always the last of the output, you could just check that `lines[-1].startwith('bound to')`.  Not that I'm suggesting you change it to that, that seems pretty brittle.  But if you think about it, the output text is really 10-20 lines at maximum and the regex engine in python is written in super fast C which doesn't have the overhead of the python loop or the function calls in python.  Even on a Raspberry Pi, I don't think the regex is going to be significantly slower or heavier than the other code and since you wrote a regex to do the final parsing, you might as well use it to do the searching too.