Ensure lines are integers before using them as strings [Fixes #872]

The problem was that they could be Rational's if the mathn library was
required.