As far as I know MACH output .mldose file looks like this:
64745 MLDOSE 1 1 0 1 1 1 1 2
64746 MLDOSE 0 2 0 2 2 2 0 2
64747 MLDOSE 0 2 0 2 2 2 0 2
64748 MLDOSE 0 2 1 2 2 2 0 2
Where first column is PatientIDs, so cut -f1 -d" " > myPatientIDs.txt should give you PatientIDs.