Implementation of open file hook