Can you just strip out the trailing whitespace (spaces and brs) before comparing ?