Add docstrings to _write_data and _write_output_directory