Cope better with blank lines at end of file