hi
I think you are reading from "office out" in r+ mode,and your writing to the same file.so it will be a infinite loop..because when write to the same file it will again not reaching EOF.
i think so..if any mistake forgive me..