got the program to start producing output
Fixed issue with detecting EOF
everything seems to be working