Moved the writing of the pact file into the complete callback.