Remove extra newlines in program output