[lib] move the double-space remover below the 'loop' so it only happens once.