read file only returning the first two charaters

I am trying to do a basic file read and return the second piece of data in a line. My text file reads like this:
/folderloc/blah/blah, true

When I run this script, the display alert only returns the first two charaters of the line instead of the whole line. It also returns them reversed( “/f” ) What am I doing wrong?

set AppleScript's text item delimiters to {", "}
set thePath to (path to desktop as Unicode text) & "tempData.txt"
set DataFile to (open for access file thePath)
set tempContents to (read DataFile)
close access DataFile
display alert tempContents
set tData to every text item of tempContents
set txtvar1 to item 1 of tData
set txtvar2 to item 2 of tData

Not sure what your problem is.

If you’re just reading a file, then you don’t need to open it. Also, you shouldn’t change the text item delimiters until you actually make use of them, and you should always set them back.

This works fine for me:

read alias ((path to desktop as Unicode text) & "tempData.txt")
set tData to result

display alert tData

set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ", "
set tData to text items of tData
set AppleScript's text item delimiters to ASTID

set txtvar1 to item 1 of tData
set txtvar2 to item 2 of tData

That’s puzzling. Byron’s script should work if the text file contains what he thinks it does. It’ll error after the alert if the file contains anything other than string text, but I can’t think why the alert should only display two characters. :confused: It’s worth checking out the file, though.

if there is always a space before the second part and it contains only a single word:

set theText to read file ((path to desktop as Unicode text) & "tempData.txt")
set txtvar2 to last word of theText

Thanks guys. I tried Bruce’s code and got the same problem. I recreated my text file and tried my old code once again and it worked. It’s weird, there are no indications that the file has problems. It opens fine in an editor and doesn’t act at all like it has a problem.