open file implementation