If you just want to read the file, but not updating it while it's "locked" then you could set the immutable flag on it :
[~]@ubuntu-s-1vcpu-1gb-nyc3-01
(0) matias #> sudo chattr +i food.txt
[~]@ubuntu-s-1vcpu-1gb-nyc3-01
(0) matias #> lsattr food.txt
----i---------e--- food.txt
[~]@ubuntu-s-1vcpu-1gb-nyc3-01
(0) matias #> rm -f food.txt
rm: cannot remove 'food.txt': Operation not permitted
Of course if you have to write to it while your script runs then this will not work and also if another user has sudo access then it can remove the immutable flag and delete it afterwards of course.
This would be more security by obfuscation rather than being bullet proof.