Refactory.

Separate calculate metrics method from the print and writer results
methods.