Script now takes a directory path instead of filename for the output.