java.io.IOException: Stream closed - unable to fix