Since you already did most of the job, you probably found out, with Johnsold help, how to solve the last problem. Anyway here is a possible solution. After stripping off the header, the file is copied in chunks of reasonable size (10 Mbytes) to a new file. The last chunk is processed to remove the footer before copying.
It is even possible, after some modifications, playing with offsets, to rewrite the file over itself.
You should also know that the footer can be removed without being obliged to rewrite the whole file, just by moving the EOF (End-Of-File) mark. Without header, that would have been from far the best solution...
CC
Chilly Charly (aka CC)