The problem with merging files is that you have to identify how to merge loops back which can be pretty complicated. The purpose of the unbundling is to break-up the file into individual units for processing. I would only attempt a rebundle if
you are truely trying to maintain the integrety of the file with all possible segements (even ones you are not concerned with).
The easier method would be to just parse your file into a flattened format and then reproduce files by looping through your parsed data format. The files you create would only include the elements that you parsed (any extra segments might be lost),
but if you are doing this just for internal processing.
The attempt to rebundle would be most valuable if you have downstream processes that might need more segments than what you are immediately concerned with.
Just be careful, there really isn't a single identifier that let's you know two loops were originally the same loop (this only exists at the ISA, FG, and ST segments), so you really need to compare the entire loop header to ensure that it's the same loop
that can be merged back.