Make sure to close the file on error

Maybe it shouldn't close in EncodeAssembly at all, though?

Not sure I understand the flow of closing the file.

-[Unknown]