def _write_device(out, device):
    """Write a single device to file."""
    attributes = []
    if device.name is not None:
        attributes.append(f'name: {device.name}')
    if device.tracking_device_id is not None:
        attributes.append(f'tracking_device_id: {device.tracking_device_id}')
    if device.disabled:
        attributes.append('disabled: True')
    out.write(device.push_id)
    out.write(': {')
    if attributes:
        separator = ', '
        out.write(separator.join(attributes))
    out.write('}\n')
