#include #include #include ; filename to read $file_to_read = "isc480.txt" ; filename to write $file_to_write = "isc480.new.txt" ; open file to read and store the handle $handle_read = FileOpen($file_to_read, 0) ; check the handle is valid If $handle_read = -1 Then ; show warning and exit with code 1 MsgBox(0, @ScriptName, 'failed to open handle to read the file') Exit 1 EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($file_to_write, $FO_APPEND) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred while writing the temporary file.") Return False EndIf ; loop through each line of the file While 1 ; read each line from a file $line_read = FileReadLine($handle_read) ; exit the loop if end of file If @error Then ExitLoop ; write to the ini file if StringInStr($line_read, "LineDisp_iSC480") = 1 Then MsgBox(0, "Result", "LineDisp_iSC480 was found, no need to append") ; close the file handle for read FileClose($handle_read) ; Close the handle returned by FileOpen. FileClose($hFileOpen) Exit 1 EndIf FileWriteLine($hFileOpen, $line_read) WEnd ; close the file handle for read FileClose($handle_read) ; Close the handle returned by FileOpen. FileClose($hFileOpen) ; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen. MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & FileRead($file_to_write))