Changed to write and read from dataDirectory