Table names (i.e. layers, blocks, linetypes etc.) which contain the pipe character are xref-dependent items, with the content to the left of the pipe equal to the name of the xref from which they are derived.
Without testing the code, I suspect that the error arises because one of the attribute values is null, as the variables holding each attribute value are not tested for validity following evaluation of the foreach loop before being pushed onto the main data list: