Used blocks to refactor File open and close commands