Split out the "finished write processing" code into a function so it can be called