Getting the Mode with that method is possible when MAPDL is in the Solution module but after the solve. When post processing the style of the *GET command is different. Instead use the SET command to read in the specific mode, then get the frequency of the result set. Like so:
Continue on with opening and writing to the file.