Split dimacs generation from argument parsing

Would you mind splitting the conversion into another function? It is easier to test this way because I can feed the function StringIO objects instead of files.