Since the script is your own, you should consider removing the newline if the length is > 30.
Excel would have the same problem.
Alternatively, you can concatenate the trimmed contents of all the fields thus:
If the data is in column A1 (row 2 in this case), the formula
Code:
=CONCATENATE(MID(A1;1;3);MID(A1;31;3);MID(A1;61;3);MID(A1;91;3))
should do.
If needed, you can further modify the formula to check the length of the string in A1 using a series of nested immediate ifs.
Eg:If(len(a1>90);CONCATENATE(MID(A1;1;3);MID(A1;31;3);MID(A1;61;3);MID(A1;91;3));if(len(a1>6)..