Added writing back to output.