Implemented logic for recursive word searching.