correctly handle \r at end of string by using strip