Example of extract UserDefaults Key to make TSV

Simple example showing extraction of UserDefaults Key
In this example I use NSUserDictionaryReplacementItems to make tsv (Tab-separated values) to be
saved on the desktop.

use framework "Foundation"
use scripting additions

set savePath to POSIX path of (path to desktop) & "userDictionaryReplacementItems.tsv"
set userDefaults to current application's NSUserDefaults's alloc()'s init()
set theDict to userDefaults's dictionaryRepresentation() as record

set replaceItems to theDict's NSUserDictionaryReplacementItems
set replaceItemsCount to count replaceItems

set theResult to ""
repeat with i from 1 to replaceItemsCount
	set {theReplace, theWith} to {replace of (item i of replaceItems), |with| of (item i of replaceItems)}
	set theItem to "Replace" & tab & theReplace & tab & "With" & tab & theWith
	set theResult to theResult & theItem & return
end repeat

set theString to current application's NSString's stringWithString:theResult
theString's writeToFile:savePath atomically:true encoding:(current application's NSUTF8StringEncoding) |error|:(missing value)