Why is this?
Could be because the writeTo() function is nested inside loop(). Though that is very hard to tell with the poor formatting. Use Tools + Auto format to straighten out the indenting, and see where writeTo() is actually implemented. It can not be inside loop().