keepends as a splitlines kwarg is not supported on Python2