Partial Python implementation of grep using O(n) string search algoritms