split finishWriting call into util method since it should only be implemented once