Spotlight and Writing to a Text File

I’m making a very simple app that uses the write command to write text to a file. The purpose of this is so I can write notes, have them saved as text files in one folder, and then use spotlight to search them later. The files are being written properly (txt files) but Spotlight doesn’t see the text inside them. Does anyone know why?

After I set the value of theNote from a dialog box I write the file to the hard drive with the following code:

set fileRef to (open for access theFile with write permission)
write theNote to fileRef
close access fileRef