The record has a variable length. An attempt has been made to write out more bytes than the record currently contains.
Change the program so that the value of the lengthItem or occursItem is within the size of the record.