I thought you said that you were using an array? Arrays have indexes, my friend, and you can use a for loop to go through the array a remember the lines you like. Otherwise, you can use grep to create a new array with only the lines you want to process