add trailing '|' and newline if missing