on truncated files just treat them as EOF
track analysis connections, make sure to end them, flushing
pending data to the file - also fix and move some stuff