You're executing the code during after phase of render response. That's thus after JSF has rendered and completed the response. At that moment, the whole HTTP response is already finished and completely sent to the webbrowser.
This is a point of no return. Your code is simply being too late in order to change the response.
Listen on restore view phase instead. Or, better, use a servlet filter. A JSF phase listener is an overly clumsy tool for the job (it does not kick in on non-JSF requests and is triggered up to 12 times during a JSF request). A servlet filter is the right tool for the job. You can find a concrete example in this answer: JSF page style missing when using login filter.