diff --git a/source/Sylvan.Data.Csv/CsvDataReader+Async.cs b/source/Sylvan.Data.Csv/CsvDataReader+Async.cs index 3b17c73..acea491 100644 --- a/source/Sylvan.Data.Csv/CsvDataReader+Async.cs +++ b/source/Sylvan.Data.Csv/CsvDataReader+Async.cs @@ -142,7 +142,8 @@ async Task InitializeReaderAsync(CancellationToken cancel = default) } if (this.newLineMode == NewLineMode.Unknown) { - this.DetectNewLine(); + var m = this.DetectNewLine(); + this.newLineMode = m; } this.minSafe = delimiter < '\r' ? '\r' : delimiter; diff --git a/source/Sylvan.Data.Csv/CsvDataReader.cs b/source/Sylvan.Data.Csv/CsvDataReader.cs index e1b327f..fc849fc 100644 --- a/source/Sylvan.Data.Csv/CsvDataReader.cs +++ b/source/Sylvan.Data.Csv/CsvDataReader.cs @@ -294,7 +294,7 @@ NewLineMode DetectNewLine() var c = this.buffer[idx]; if (c == '\r') { - if (c + 1 < this.buffer.Length && this.buffer[c + 1] != '\n') + if (idx + 1 < this.buffer.Length && this.buffer[idx + 1] != '\n') { return NewLineMode.MacOS; }