Moved pipe to cache file outside the bash invocation.

If we put it inside the bash invocation, then it fails on pipelines
because it's piping the last command and not the pipeline as a whole.
Also there might have been some quoting issues which now definitely
don't exist.