The linearize-data contrib script does not quite work correctly in the case of a chain reorg, and it fully-truncates files with an incorrect open mode.
This small patch clips off incorrect trailing data and corrects file open mode type.
(small patch being passed around which I did not write but thought would be helpful to the community)