replace newlines with commas in text