vbscript for each array
<p>I'm looking to pull a text document or single field CSV document into an array then loop through the array.</p>

<p>I've been through a few examples on here but continue to fail to get the script working.</p>

<p>Any insight would be appreciated and sorry if I missed a previous useful posting.</p>

<pre><code>    #$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

Sub Main
Set fso = CreateObject("Scripting.FileSystemObject")

Set hosts = fso.OpenTextFile("C:\Users\XXXX\Documents\2016\3 SmartServices\SNMPHosts.txt")



Do Until hosts.AtEndOfStream
    strNextLine = hosts.Readline 
    arrServiceList = Split(strNextLine , ",")   
Loop 

hosts.Close

For Each item In hosts
    crt.Screen.Send "telnet " &amp; item &amp; chr(13)
    crt.Screen.WaitForString "username: "
    crt.Screen.Send "UUUU" &amp; chr(13)
    crt.Screen.WaitForString "password: "
    crt.Screen.Send "PPPP" &amp; chr(13)
    crt.Screen.WaitForString "&gt;"
    crt.Screen.Send "en" &amp; chr(13)
    crt.Screen.Send "PPPP" &amp; chr(13)
    crt.Screen.WaitForString "#"
    crt.Screen.Send "conf t" &amp; chr(13)
    crt.Screen.WaitForString "(config)#"
    crt.Screen.Send "COMMAND STATIC TEXT" &amp; chr(13)
    crt.Screen.Send "COMMAND STATIC TEXT" &amp; chr(13)
    crt.Screen.WaitForString "(config)#"
    crt.Screen.Send "end" &amp; chr(13)
    crt.Screen.WaitForString "#"
    crt.Screen.Send "wr" &amp; chr(13)
    crt.Screen.WaitForString "#"
    crt.Screen.Send "exit" &amp; chr(13)
    crt.Screen.WaitForString "WAIT END STRING"
Next
End Sub 
</code></pre>