Updating write_interim to include comments and debug flags