Because a quoted field takes every character literally, a newline inside the quotes belongs to the field rather than ending the record. Today you confirm one record can span several physical lines, the feature that lets a CSV cell hold a paragraph.
Keep a newline inside a quoted field as part of the value, so the record does not end there.
The newline is the record separator, but only when it is outside a quoted field. Inside quotes, every character is literal, and a newline is no exception, so a quoted field can contain a line break and the record simply continues past it. This is the feature that lets a single cell hold a multi-line note or an address block, and it is the reason you cannot count a file’s records just by counting its newlines. The number of rows depends on the quoting state at each newline.
The change is small because your state machine already tracks whether it is inside quotes: the only thing that decides whether a newline flushes the record or joins the field is that one piece of state. When quoted, append it; when not, flush. Test the interaction directly by checking that an input with an embedded newline still produces exactly one record, not two. This is where the earlier record-splitting rule and the new quoting rule meet, and getting their interaction right is the whole point of building a state machine rather than splitting on newlines first and commas second.
// in QUOTED mode a '\n' is an ordinary character, appended to the field// only an UNQUOTED newline flushes the record (the rule from lesson 3)// so the record-flush check must ask: am I inside quotes right now?// if quoted -> append the newline; if not -> flush the record