It seems to me that the following:
$ sed 's/\r$//' file.txt | sponge > file.txt
with sponge from moreutils results in an empty file.txt, whether or not file.txt initially contains text. I don't believe the sed filter is special here, it just happens to be what I was using when I encountered the issue.
Is this reproducible on your machine? Why isn't sponge "soaking" up the output from sed before the shell opens file.txt for writing?