Formatting improvements to 6, 7, 8, 9

Also, in Lesson 9, corrected the type of variable 'loop',
and made it local to each use.