Refactored the reading of the input data so we read the tempfile only once