What exactly do you mean by string to break when a $ is pressd instead of new line? Is it while reading from keyboard or what is the scenario you are having?