Using EN's data file tool I wrote a simple hotkey script to write a rail data file as follows:
Set %Rail_Name SPR1
Set %File_Name %Rail_Name
Set %File_Name_txt %File_Name , .txt
Set %File_Path C:\Users\CRS\Desktop\EUO\
Set %File_Path_And_Name_txt %File_Path , %File_Name_txt
Set %WP_Save WP
GoSub ENs_ClearFile %File_Path_And_Name_txt
Set %X 0
Repeat
      {
      onhotkey f4
      Set %HotKey4 True
      onhotkey f5
      Set %HotKey5 True
      If %HotKey4 = True
         {
         Set %X %X + 1
         Set %WP_Save . %X %WP_Save , %X
         Set %WP . %X X . #CHARPOSX , Y . #CHARPOSY , Z . #CHARPOSZ
         Event exmsg #charid 3 4 %WP . %X
         gosub ENs_SaveData %File_Path_And_Name_txt %WP_Save . %X
         Set %HotKey4 False
         }
      }
Until %HotKey5 = True
Set %WP_Count %X
Gosub ENs_SaveData %File_Path_And_Name_txt WP_Count
Halt
I ran the code, hit F4 four times and then hit F5. The rail file is named SPR1 and looks like this:
; ENs Var Save 
Set %WP1 X2164Y2169Z7 
Set %WP2 X2164Y2169Z7 
Set %WP3 X2164Y2169Z7 
Set %WP4 X2164Y2169Z7 
Set %WP_Count 4 
Next I will add in the character count code.