>>10
You don't seem to be closing the file if
channels != 1. I knew this would be the case as soon as I saw that you
1. Was handling a file, &&
2. Used proportional fonts for coding.
I've never used Acme, but can't you set it to use a proper programming font?