fixed bug when the pattern end with newline and -n option