Compact input buffer before trying to read instead of after.