regularize parameters
move fileopen to main()