Basic infrastructure for writing to file.