Write to and read from a file