corrected xmlreader so write segfaults less often