Fixed logic for file input