Fix last_line_blank logic

The broken last_line_blank logic could lead to random failures in the
API tests.
Merge pull request #237 from nwellnhof/fix_last_line_blank

Fix last_line_blank logic