added missing writeEndArray