Close open file at the end of the run.
Allow the solutions to be output to different LaTeX files.

Fixes #4.