Maybe move the calls to ```out.close()``` out of the ```catch``` statements and into a ```finally```?