Made the try-with-resources converter more versatile