PPP Profile scripts

Hi, I’m new to scripts. I made a mistake somewhere, but I don’t know where.

PPP Profile Script On Up:

:local DateTime ([/system clock get date] . " - " . [/system clock get time] . "   ");
:local PPPProfileFile [/file get flash/PPPProfile.txt contents];
:local PPPProfileLog ($DateTime . $user . " connect with private IP address " . $"remote-address" . " from " . $"caller-id");
:set PPPProfileFile ($PPPProfileFile . "\r\n" . $PPPProfileLog);
/file set flash/PPPProfile.txt contents=$PPPProfileFile;

PPP Profile Script On Down:

:local UserUpTime [/interface pptp-server get $interface uptime];
:local DateTime ([/system clock get date] . " - " . [/system clock get time] . "   ");
:local PPPProfileFile [/file get flash/PPPProfile.txt contents];
:local PPPProfileLog ($DateTime . $user . " disconnect. Uptime connection - " . $UserUpTime);
:set PPPProfileFile ($PPPProfileFile . "\r\n" . $PPPProfileLog);
/file set flash/PPPProfile.txt contents=$PPPProfileFile;

Does not save the users uptime in the file. Can you show me where I went wrong?