writing and reading structures using binary files