Correct a bug with newline empty.
Add tests