An io.Reader exposes bytes through a small interface. Code can process a string, an in-memory buffer or a file through that same boundary, without knowing where the data came from. Reading all bytes is convenient for a bounded payload; line scanning is useful when records arrive one line at a time. A scanner can stop because it reached the end or because it failed, so inspect Err after the loop. Its default token size is limited. These exercises use local memory streams only, which matches the browser environment. They do not open files or make network requests. You will keep blank lines when the request calls them records, total line lengths and refuse a deliberately failing reader. Cleanup for an owned resource belongs with the caller that opened it.
Keep bytes including newlines.