Implemented writing RDP file to disk

TODO: Optimize by only writing the fields that have a value i.e
~((size_t) file->FieldName) != 0

Fixed wfi leak.
Fixed insufficient mem alloc.