using open file handles instead of commandline