just to be slightly more defensive, I would probably write

```
if not stat.endswith('\n'):
    stat = stat + '\n'
```

that way you'll still Do The Right Thing if someone passes newline-terminated stats into you, and you'll be slightly DRYer