Fix a bug where the compiler would try to close the wrong stream when processing an error generated while checking a source file for an `encoding/1` directive