Preparing for writing to file