I find it really interesting that piping to `tee` breaks things, but that piping to `grep` doesn't.  I'd love to know more about how you discovered that this was the problem! :)