fix "offset out of bounds" issue with empty htpasswd

close #2

+ get rid of possible fd leaks