I'm pulling a gzipped xml file from a remote web site (all OK), when I open this with gzopen and stuff it into simplexml_load_string it fails with an incomplete read. I've changed the code about to exec "gzip -d myxml.gz" and this still fails to produce a full valid XML file The php exec returns gzip: /tmp/myxml.gz: unexpected end of file However, if I bypass the PHP invoked gzip and decompress the file manually with gzip -d myxml.gz from the shell I get a complete valid xml file and re-run the php script it is happy to read the entire file into simplexml. I get the same response when run via an Apache triggered event or manually via php-cli. I'm using Drupal 7, but don't think this should make any difference. Any suggestions welcome.