Try rewinding the stream after line 20:
Code:
li.QuadPart = 0;
pIStream->Seek(li, STREAM_SEEK_SET, NULL);
gg