From: tamouse mailing lists Date: 2013-01-13T01:00:27+09:00 Subject: Re: How to take information from a text file and add them to an array On Sat, Jan 12, 2013 at 8:00 AM, Adam Kennedy wrote: > So If I have a variable with a password in such as pswd = example. > And in the text file there is 50 different user passwords. How can I > make a function that picks out the single word from the line of 50? passwords = File.read("passwords.txt").split("\n") pswd = 'example' if i = passwords.find_index(pswd) # do stuff with found password at index i else # not found end