added function to read or write to file