You are effectively using the filesystem as a database and trusting that the directory-entry correctly reflects the file size. Benchmarking will probably reveal that your approach is slower. Read the preferences from the database once and keep them in memory. Don't retrieve them in a loop.
Thank you. I'm always leary of too many database calls, but it appears too many Apache calls can be equally, or more taxing.
I have no idea how to write to particular part of a .sub file so I did the workaround.