Fixing null exceptions when io streams can't be read