I'm currently trying to write a script for my remote users to run a backup that will compare the files on their local machine. The problem is the file I want to use for logging. It does not replace the line, instead it appends the info. Can any help me with replacing the text instead of appending?

Thanks,

Tom

code:
;***** Find where the users My Documents folder is and backup if not on server.

; $Location is the location of where My Documents is located in the registry
; @HomeDrive is the drive location that User Manager has the Home drive as
; $Source is the Path that robocopy uses for Source
; $Dest is the Path that robocopy uses for Destination
; $File is the Filename that robocopy uses
; $Opti is the Options that robocopy uses
; $ShellCMD is the command line that is passed out to run

;***** Edit or Create a log of the backup.
; $FileName the path and name location of the log file
; $X line read from UserBackup.CSV
; $Found if the string is found or not found
; $LineToWrite the information of when the user did a backup

;DEBUG "ON"

$Location = ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Personal")
If @ERROR = 0
If Left($Location, 2) = @HomeDrive
? "The location of My Documents is on the server already no backup needed."
Else
$Source = $Location
$Dest = Chr(34) + "F:\My Documents" + Chr(34)
$Opti = "/R:3 /Z /Mir"
$ShellCMD = "RoboCopy " + $Source + " " + $Dest + " " + $Opti

Shell "%comspec% /c $ShellCMD"
EndIf
EndIf


$FileName = "C:\Data\UserBackup.csv" ;eventully to be placed on server.
$X = ReadLine(1)
$Found = 0
$LineToWrite = %username% + "," + @Date + "," + @Time

OPEN(1, $FileName, 5) ;UserBackup file created to track when users backup.

While @Error=0
If INSTR ($X, %UserName%) <> 0
$X = WriteLine (1, $LineToWrite)
$Found = 1
EndIf

$X = ReadLine(1)
Loop

If $Found = 0
WriteLine (1, $LineToWrite)
EndIF

Close(1) ;Close UserBackup.csv file

Exit



Current log file.
Tom.Hagen,2002/09/07,21:16:49Tom.Hagen,2002/09/07,21:17:13Tom.Hagen,2002/09/07,21:17:17
_________________________
Tom Hagen Jr Power comes from the Mind.