Made it work with command line (taking filename as an argument)