Fix bug in protocol which opened and closed file on every append