Generating the final main file