```go
if _, err = fmt.Fprintf(file, "%d", os.Getpid()); err != nil {
```
simplifies the writing a bit.