You can put the header and footer in separate files and cat all together:
cat header original_file footer > new_file
mv new_file original_file
This command concatenates three files into one new file and the renames the file.
If the header and footer are generated while running some programs you can do:
program_producing_header > new_file
cat original_file >> new_file
program_producing_footer >> new_file
mv new_file original_file
First this runs one or a series of commands which produce the header and writes them into new_file. If the file exists will be emptied first. The second line appends the contents of your original file to the new file and the next appends the output of your footer program. The last line renames the new file to the name of your original file.