In this case you need a counter: ;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Global $aText[] = ["01_TextFile", "02_TextFile", "03_TextFile"]
Global $sDirforTxtFiles = "C:\Temp\"
Global $iFound = 0
$sUsername = @UserName ; Pulls username that is logged in
;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
; SCRIPT START
For $i = 0 To UBound($aText) - 1
$hTextFile = FileOpen($sDirforTxtFiles & $aText[$i] & ".txt", 0)
$sReadText = FileRead($hTextFile)
FileClose($hTextFile)
If StringRegExp($sReadText, $sUsername) Then
$iFound = $iFound + 1
MainScript()
EndIf
Next
If $iFound = 0 Then NotInTextFile()
If $iFound > 1 Then FoundMultipleTimes()
Func MainScript()
MsgBox(0, "USER FOUND", "In following textfile: " & $aText[$i])
EndFunc ;==>MainScript
Func NotInTextFile()
MsgBox(0, "", "USER NOT IN ANY TEXTFILE")
EndFunc ;==>NotInTextFile
Func FoundMultipleTimes()
MsgBox(0, "", "USER FOUND MULTIPLE TIMES")
EndFunc ;==>FoundMultipleTimes