Removing stray newlines to prevent unwanted whitespace in output