I am trying to write a script that reads the first line from TextA (an item name), look it up in a database, convert it to an itemid and write the ID in TextB.
For some reason this doesnt work. Thanks for your help in advance 
PHP:
function main()
{
Declare Buffer binary
Declare File file TextA.txt
Declare FP filepath "${Script.CurrentDirectory}"
Declare File file TextB.txt
Declare FP filepath "${Script.CurrentDirectory}"
string currentitem
;;Loading DB
LavishSettings:Import[${CONFIG_FILE}]
LavishSettings[${SET_NAME}]:GetSetIterator[itemIterator]
;; Read first line and convert to TypeID
Position=${TextA.Position}
currentitem=${TextA.Read}
TypeID(currentitem)
Write=${TextB:Write[" ${currentitem} , ${TypeID}"]
return
}