make sure file extension check is case-insensitive, and close files