Added compile flags to makefile and gave function open a 3rd argument - apparently required.