Prepare to refactor out write_recipe

Rearrange write_recipe and write_file so they are contiguous in
recipe.py. Rename some variables to make things more intelligible.