fixed empty string handling at the end of line