Added small untested code to close the outputwriter