Write the stage script to the stage directory