add the logic to skip the endding line break