Hi,
I am not 100% sure how your input looks like and how your output should look like.
As far as I could understand you want to run a program with two command-line parameters <ip> and <port>.
The ip is read from a file and is an array of IPs with each IP seperated by a given character throughout the file.
If you're using bash (dunno on which other shells it'd work) you can use this little script to get the job done.
CODE
#!/bin/bash
IFS=$'token delimiter, eg: \n to handle input line-by-line'
for ip in $(cat $1)
do
exploit $ip 31337
done
Write it into a file and do 'chmod +x file' once to mark it as an executable file.
Execute it with the filename of the input file as the first parameter.
To use it as a one liner you have to seperate the lines in the script with a semicolon and replace $1 with the input filename. The #!/bin/bash must not be include in a one liner.
If you have any questions or anything else to say feel free to do so.