Reworked grep error handling.