0. Create a new empty line, and make it the current one. 1. Find the first fragment in the list that fits on the line. 2. If there is no such fragment, goto 0. 3. Add the fragment to the current line, and remove it from the list. 4. If the list is empty, you're done. 5. Goto 1.