Otherwise strchr() can crash for files that don't end with '\n' because it won't find a null char to terminate at. Fixes #2934