We can fix (23) Failed writing body error while piping cURL to some programs like grep by using an intermediate such as tac which by default reads line from last.
Example
$curlhttps://{SOME_URL}|tac|tac|grep{PATTERN}
Note: Using tac as it will first reverse the order, and then reverse it again to get the original body.