Added automatic object file name determinition. Write object into file.