if your on linux: just cron it. if your on windows: i have a console hide function i think ( i cant remember if i got rid of it) and you can just have it continuosly run in the background and have it write to file every 2 mins
since your code will exit after you write it.
1. the Sleep is in milliseconds, 1 second = 1000 milliseconds, so Sleep(2000)
2. write two calls of Time() function cannot help to run it forever, you can try
3. you can also try to use for in windows cmd, for /L %i in (0,0,1) do (your_app.exe)