Fix bug of appending to an existing gzip file