Added code to read from/write to directories