$ man sponge
...
sponge reads standard input and writes it out to the specified file.
Unālike a shell redirect, sponge soaks up all its input before opening the output file.
This allows constructing pipelines that read from and write to the same file.
This is the expected behavior of pipes[0]. A quick look at Lists [1] clears up how you can control this a little better (+Job Control). jamesdutc also linked to sponge, which may suit your usecase as well.
The shell sets up the pipe and file redirections for each process in the pipeline, then lets them go. It has no control over when the child processes read or write. It could be a race condition, but it's written in such a way that it appears that the file will get truncated before it can be read virtually 100% of the time.
Counteranecdatum for the author: I find your choice of foreground and background colors, syntax highlighting colors, font style and size, and line length inside your code blocks to be quite legible and pleasant to read.
Please make these sorts of choices again in the future!
I see your point about the larger fonts but I have used the sunburn theme for a while in my editor (not anymore thought in favor of slightly customized naquadah[1] ) and I feel quite a bit more comfortable reading code in familiar coloring.
I chose this color scheme because sunburn dark is quite popular.
Perhaps your color vision is now at the point where you should consider loading an accessibility stylesheet into your browser. I don't look forward to the day when I am required to do this, but I do know that it will inevitably arrive.
It seems that some of the stylesheets are broken for HTTPS. Note that this is not https-everywhere breaking the site; simply switch the URL to https://, and you will see what I see.
Also, see `sponge` from `moreutils` (http://kitenet.net/~joey/code/moreutils/):