moved a check before open file