Refactoring: Make filter functionality for system tools line-based
This is more efficient as:
- All existing filter functions were line-based anyway. They broke up the input into lines and then joined it back together.
- We already break up the output from system tools into lines when processing it.
Splitting up the output of system tools once and then filtering and processing it reduces both code and runtime complexity.