Allow file object instead of filename in read_preference_file