m.StoreMessage = .F. .... FOR ix=1 TO ALINES(laLines,strProcessData) .... DO CASE CASE m.Segment = 'MSH' m.StoreMessage = .T. ....maybe in the last message the loop didn't goes through this branch of CASE? What happens if you remove check for StoreMessage in the IF?