Hello Peter,
According to Microsoft Learn documentation, the File.ReadAllLines method removes line terminators (\r, \n, or \r\n) when reading lines into a string array, meaning the lines.Last() call will always return a string without the end-of-line characters, causing the code's condition to always evaluate as true. To accurately check for the presence of a newline at the end of a file, the content must be read in a way that preserves line endings, such as using File.ReadAllText which reads the entire file into a single string. For more details, visit Microsoft Learn.
Regards,
Raviteja M.