Fixed the java.io.IOException: Attempted read from closed stream error