We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Newlines

Reading 8 bytes at a time is a good start, but 8 byte chunks aren't how people tend to communicate... you probably noticed that it was hard to read the individual messages through your program.

Trust me, this all leads up to HTTP. I promise.

Assignment

Let's update our code to continue to read 8 bytes at a time, but now let's format the output line by line. It should now print the data in the same format:

read: %s\n

But now %s represents an entire line of the input file. We're decoupling how we present and parse (full lines) the data from how we read it (8 bytes at a time).

Here's what I did:

read: LINE

Where LINE is the "current line" we've aggregated so far plus the current "part". Then reset the "current line" variable to an empty string. Note that if we only have one "part", we don't need to print, as we have not reached a new line yet.

Run and submit the CLI tests.