Fix infinite loop for file input