refactored read_problem_file, which was unwieldly.