I actually asked my physics professor about this today. As he explained it, one > indicates replace everything in the file; two of them, >>, means append to the file, like add another line at the end.
So in X-Stranger's code, first you write the first line of the file (rootdev), then you append...