added write to file functionality for object orientation