These errors mean that your gz file is corrupt. There could have been an error while writing the file while running gzip -cq. As Yogesh has said before, try running the gzip -c command again without the -q option.
gzip automatically stores the zipped file in XYZ.txt.gz, you do not need to do a redirect. What you are doing with the redirect is storing any gzip messages in XYZ.txt.gz, instead of the actual zipped data.
Sorry, but that's plain wrong. The OP is using 'gzip -c'. Check the gzip man page to see what the '-c' switch does. What he is doing is fine, just removing the -q could let him see if any error is being thrown.