Added an utility function to detect final new lines.