Delay IO until after building the PPM

On my machine, which has an SSD, over 10s of time was in system. This moves writing the PPM data to file until the end, which cuts it right down. For me this corresponded to a ~25% speed increase.