Why not just make sure you aren't reading in the blank lines?
Instead of slurping the whole file into the array, use a while loop to iterate through the open file. Verify the line doesn't start with a whitespace or # (or whatever else you want to ignore), and if all is well, push that ine into the array.
The difference in speed and memory is likely negligable between the two techniques.
Instead of slurping the whole file into the array, use a while loop to iterate through the open file. Verify the line doesn't start with a whitespace or # (or whatever else you want to ignore), and if all is well, push that ine into the array.
The difference in speed and memory is likely negligable between the two techniques.