Can I just open once a file and remove all lines together having words stored in words.txt?
in reply to how to avoid opening and closing files
See map and grep
(and specially "grep (!/regex/) the_file", where regex should match words stored in words.txt
### choosing particular column and pushing all its values in single ar
I guess that a hash (%X) could be better here, but if you want an array, think in an unique sorted list or so. The idea is to avoid duplicates.