Sorry, you are right. It needs "set docA = dc.GetNextDocument(docA)" just before the wend.
The loop wasn't the point, though. The important difference is that it creates a doclink to the original document, without making docB a response. This is achieved by
dim rti as NotesRichTextItem
...
set rti = new NotesRichTextItem(docB, "CopyOrigin")
call rti.AppendDoclink(docA, "", "")