, yes, that will work, but you will always fill your memory with a lot of unnecessary data before you actually output any data.
Without saying too much (to not make the OP's homework too easy ;-)), I'd first find out which column is actually searched for, then go through the rest of the file line by line and print the only column that is requested.