Inserted code to handle outfile header construction.