+ # Reverse the ranges so that the reformatting does not influence file offsets. + ranges.reverse() + + # Do the actual formatting. + for r in ranges: you can simplify this to for r in reversed(ranges): -- Sean Silva