in reply to Modify zip file in memory

You will have to do your modification in two steps:

  1. Write your changed version to a new file
  2. Overwrite the original file with your changed version

Also, I think that Sharepoint automatically inserts markers into files that look like (zipped) XML to track whether a file was copied/renamed and still reference the history.