fixed double file open to check the device