diff --git a/variables.go b/variables.go index 2bdf80d..735b843 100644 --- a/variables.go +++ b/variables.go @@ -210,6 +210,9 @@ func (i *IBT) Update(timeout time.Duration) (IRacingState, error) { start := i.Headers.BufOffset + i.Vars.Tick*i.Headers.BufLen buf := make([]byte, i.Headers.BufLen) _, err := i.File.ReadAt(buf, int64(start)) + if err == io.EOF { + return Ended, nil + } if err != nil { return Unknown, err } @@ -219,10 +222,6 @@ func (i *IBT) Update(timeout time.Duration) (IRacingState, error) { log.Fatalf("What happened?\n%v\n", err) } - if err == io.EOF { - return Ended, nil - } - // This was previously in the read data method, but it probably fits here better i.Vars.Tick++ }