Write back file when it's closed.