further cleanup

moved the isopen() check to a function
typo fix

fix to typo
function prototype should be int
Merge pull request #2 from thisisnian/master

moved isopen check to it's own function