Can't write data into variable

As requested, post all your code.
Make sure you check that the file has opened successfully with:
if (dataFile) { ... } else { /* failed */ }