Don't forget to remember previous element at the end of the loop.

Reported by:	brueffer
Found with:	Coverity Prevent(tm)
CID:		1135301