added os to handle file extension, added blank lines to improve readability