Writing a simplified, cross-platform grep clone in Python