Very simply just have a 0 byte anywhere, either in the output of a program…
or in a file you downloaded…
and it will only copy the parts before the 0 byte, so “hello” and “HEAD”, respectively.
I repro’d this on Ubuntu and Windows, respectively, so it doesn’t seem to be OS-specific.