Fix for #159. Correct a bug in Cop#keywords.

In the old code we get stuck pushing and popping keywords when 'def'
is the last keyword in the list. Reworked the algorithm a bit.
Merge pull request #160 from jonas054/avoid_for_bug

Correct a bug in Cop#keywords.