"I write a book."
Translation:Yo escribo un libro.
You say un because of the masculine and feminine grammar rules.
Un goes with masculine, Una goes with feminine.
We say "un libro" because libro is masculine (we can tell because it ends in an o).
We would say "una manzana" because manzana is femenine (we can tell because it ends in an a).