open file properly