Remove Spaces at EOL, fixed if test on pattern variable