Fixes #291: Use writeIfDifferent

It's a little heavier on memory and disk, but it gives us more consistent builds.