try-with-resources around baos