Q:

When I write to a text file in python 3.5.1 the text file is blank

I'm writing to a text file but the final content is blank. Can anyone help.
def main():
    types = input('What is the device type? Phone or Tablet')
    save = open('type.txt', 'w')
    save.write(types)
    save.close
    if types == 'phone':
        import Type1
    elif types == 'tablet':
        import Type2
    else:
        main()

main()

I've tried what I could but I'm not an expert on python.

A:

In Python every method call is with parentheses. Just use save.close().

A:

The save.close part should be the culprit here. Try changing it to:
save.close()

It can be a hard bug to catch because this won't cause an exception. The interpreter will silently return a value such as:
<built-in method close of _io.TextIOWrapper object at 0x003E7CB0>

Try entering in the contents of main() line-by-line interactively to see an example if you'd like.
The following would be even better, as you wouldn't have to call the close method yourself:
with open('type.txt', 'w') as save:
    save.write(types)

