-n reads the file line by line. Have you looked at what $_ contains for each of your checks?
In reply to Re: how to deal with newline by Corion in thread how to deal with newline by nvdierdo