in reply to joining lines

One strategry is to simply avoid rejoining them and parse on the |. That way newlines wouldn't matter. You can try changing the field seperator and see if it doesn't take care of this all for you, or you could use split or a regex across multiple lines not taking into account the \n character to grab your fields.

It appears as though you are going 4 fields to a record with the field seperator of '|'.