the '4' means it's the 5th element, so first the relations of the typed list, then the relations you add.
Ok, it works, which is logical. then you remove the relation shipToRelation, so MyCdfLineEntity.Relations.SubprojectCdfLineEntityUsingCdfId becomes relation at index 4. Then you add shipToRelation again, which is appended to the list at the end.
The RelationCollection.ToQueryText method walks the relations, and arrives at relation at index 4, MyCdfLineEntity.Relations.SubprojectCdfLineEntityUsingCdfId. As there are already relations processed, only an 'INNER JOIN entity' will be added, not an 'Entity INNER JOIN entity' (or whatever join type). This means that at least one of the entities in the relation has to be present in the pack already. This isn't the case, as the relation which makes this possible, shipToRelation, hasn't been processed yet as it is the last relation in the list.
This 'ordering' of relations is important, as LEFT/RIGHT joins are supported and these require an order.