added writing to files