Drop the `if`:

```go
err = fmt.Fprintf(file, "%d", os.Getpid())
return err
```