Improved detection of MSH segment and fixed incrementing issue with empty HL7 fields.