Grep Implemented in Java