Move program preamble outside of check; Fix read() and exit() syscalls