Ma/log problem in file

This logs the problem and its solution in a file. It's a bit rough, being cut down from a prettier solution that hit some memory issues, but it does the job.