Updated string function to strip carriage returns