Added file input code, seems to be working fine.