Revised longest line program (Exercise 1-16)