Only strip newlines off the end of the text. Stripping them off the beginning can mess up offsets