@xiangli-cmu `err` cannot be nil when `n != len(data)`. You can just pass the `err` back directly.

http://golang.org/pkg/os/#File.Write