open and read function