Fixing the issue where we were double freeing memory. Also while creating a file for DeviceProfile input, make sure the file doesn't exist before creating a new fil to avoid exceptions from being thrown