flushFile, changes to other functions. Haven't tested, but compiles.