Added a condition to if statement and tested with \n