title: XMLWriter getting stuck sometimes PHP
body: <p>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.</p>
  
  <pre><code>$xml = new XMLWriter();
  $xml-&gt;openMemory();
  $xml-&gt;startDocument('1.0', 'UTF-8');
  $xml-&gt;startElement('rows');
  $xml-&gt;writeElement('TotalRows', count($total));
  
  foreach ($rows as $row) {
      $xml-&gt;startElement('row');
      $xml-&gt;writeElement('id',  $row['fba_sku']);
      $xml-&gt;writeElement('sku', $row['sku']);
  
      // There is 31 elements with calculations
  
      if (0 == $i%1000) {
          file_put_contents('example.xml', $xml-&gt;flush(true), FILE_APPEND);
      }
  }
  
  $xml-&gt;endElement();
  file_put_contents('example.xml', $xml-&gt;flush(true), FILE_APPEND);
  </code></pre>