WriteToFile should be executed eagerly too
Refactored duplicated code to SchemaRDD