$replace( $loop(a)xxx$loopend() ),x,y) is not working?

I'm trying to do a longer list of replaces around the whole ouput of a export file, but stumbled across the problem, that the text inside $loop(a)...$loopend() is not replaced.

Here is a example, melted down to the core of the problem:

$replace(xxx
$loop(%_path%)xxx
$loopend()xxx,x,y)

Output (for three files):
yyy
xxx
xxx
xxx
yyy

Is there anything I can do to get:
yyy
yyy
yyy
yyy
yyy

Since the list of replaces in my actual export is very long (URL endcoding via $replace function), I would like to achieve this without using $replace inside the $loop...$loopend.