ABS chapter 4

Ready for review.
Probably tidier to chomp the input as it's read in, rather than in the function.