Solution to the spiral printing problem.

Fixed the bugs in my previous solution.