Corrected XML stream reading/writing