Updated to read from agent file and write to db file