I need to open a file, read from it, and write back to it in my script, but the file in question is constantly getting appended to by a different script, and I want to keep it from getting appended to by the other script until I write back to it with this script. I figured I could use flock to lock the file, but is there any way I can both read and write to the same file by the same filehandle? if not, how else would I accomplish this?