This does need to be addressed, but I don't think Nalin's patch deals with a short write properly, since the written length isn't actually checked. We should also check feof and/or ferror when reads return 0. I am working on a patch to clear KTFILEP any time we close the file.