Using withInputStream v. newOutputStream

This fixes: ”java.lang.OutOfMemoryError: Java heap space”