I have a regular XMLWriter structure and its working fine, my problem is that sometimes its getting stuck in the middle of the loop and stops looping but sometimes is it going ok through the end of the loop, what can be the problem of this structure.\[code\]$xml = new XMLWriter();$xml->openMemory();$xml->startDocument('1.0', 'UTF-8');$xml->startElement('rows');$xml->writeElement('TotalRows', count($total));foreach($rows as $row){ $xml->startElement('row'); $xml->writeElement('id', $row['fba_sku']); $xml->writeElement('sku', $row['sku']); // There is 31 elements with calculations if (0 == $i%1000) { file_put_contents('example.xml', $xml->flush(true), FILE_APPEND); }}$xml->endElement();file_put_contents('example.xml', $xml->flush(true), FILE_APPEND);\[/code\]TIA