in reply to CrLf getting inserted into an octet-stream (gzip file)

Try this before sending your output: binmode STDOUT;