working open, read and write on file