An interesting approach, Aaron.
Most folks here would make OP show the current code set, to ensure they understood the whole read file/write file process, and that all they were stuck on were particulars of the logic.
You kind of took an interesting middle ground and fed him a complete-from-scratch working example, but he had to at least show enough cleverness to adapt it to his needs.
Not sure it's the middle ground I would have chosen, but it is a creative way to not do absolutely everything for the student.