Created the WriteFramesToDisk function.