Better handling of trailing \n problem.