I was able to fix the problem (and improve my code) by using shutil.copyfileobj to copy from the old file to new one.
shutil.copyfileobj