critpath.py: Split file writing into a separate function
Just to make main() a bit shorter and pylint happier. Also
simplify it, there is no way critpath could be None, and if
somehow it was, the call to `sorted` would have blown up already.
Signed-off-by: Adam Williamson <awilliam@redhat.com>