fixing the ^M trailing char problem