Fixed a type mismatch issue in the external file commandlist write loop