Nothing short of linear types prevent you from saving the open file descriptor to a variable, closing the file, then using the open file descriptor variable again.
Or rather, typestate itself needs either linear/affine types or a similar mechanism to make sure that when you are in the "closed" state you can't access methods from the "open" state, and vice-versa. (now, there are languages that implement typestate as a language feature rather than a design pattern, but I don't know how they work)