Fix bug where closing reader before reading it.